.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

URL routing with a dynamic .sitemap file

Posted By:      Posted Date: September 04, 2010    Points: 0   Category :ASP.Net
Hi,I've implemented URL routing now I've upgraded to .NET 4 following http://weblogs.asp.net/scottgu/archive/2009/10/13/url-routing-with-asp-net-4-web-forms-vs-2010-and-net-4-0-series.aspx.The only problem I've encountered is with the .sitemap file. If I put, for example: <siteMapNode url="~/recipes/Starters" title="Browse Starters"> it renders correctly. However, I need to do something like this: <siteMapNode url="~/recipes/{category}" title="Browse {category}"> - i.e. dynamically giving a titleOr, I'd settle for something like this: <siteMapNode url="~/recipes/*" title="Browse Recipes"> - i.e. covering all recipe pages Has anyone found a nice solution to this?

View Complete Post

More Related Resource Links

Routing in dynamic data applications


Im using ASP.Net 4. I tried to modified the code according to following video tutorial. http://www.asp.net/aspnet-in-net-35-sp1/videos/how-to-enable-table-specific-routing-in-dynamic-data-applications

But Product page directs only to ListDetails.aspx page.

This is my code :

<%@ Application Language="C#" %>
<%@ Import Namespace="System.ComponentModel.DataAnnotations" %>
<%@ Import Namespace="System.Web.Routing" %>
<%@ Import Namespace="System.Web.DynamicData" %>

<script RunAt="server">
    private static MetaModel s_defaultModel = new MetaModel();
    public static MetaModel DefaultModel {
        get {
            return s_defaultModel;

    public static void RegisterRoutes(RouteCollection routes) {

        DefaultModel.RegisterContext(typeof(NorthwindDataContext), new ContextConfiguration() { ScaffoldAllTables = true });


Uploading to SQL Server using AJAX muiltiple file uploader and dynamic SQL Server Tables


I am getting an error on the following code when trying to pload files directly to a database.  

 Incorrect syntax near ','.

 Incorrect syntax near 'image'.


    Private Sub Uploader_FileUploaded(ByVal sender As Object, ByVal args As UploaderEventArgs)

        Dim data() As Byte = New Byte((args.FileSize) - 1) {}

        Dim stream As Stream = args.OpenStream

        stream.Read(data, 0, data.Length)

    End Sub


Private Sub ButtonTellme_Click(ByVal sender As Object, ByVal e As EventArgs)


        Dim objConn As New SqlConnection("Data Source=mrpoteat.db.2798093.hostedresource.com; Initial Catalog=mrpoteat; User ID=mrpoteat; Password=Colgate23;")


        Dim strCommandText As String = ""

        For index = 1 To Attachments1.Items.Count Step 1

            strCommandText += "pic" + index.ToString() + Space(5)

problem with sitemap schema 'xsi:schemaLocation' in XML file creation

SqlConnection conn = new SqlConnection(connStr); conn.Open(); string sql = "select top 10 catnum,cast(case when isnull(onhand,0) < 5 then 0 else round((onhand/2),1) end as int) as onhand from dbo.V_OnHand with (nolock)"; SqlCommand cmd = new SqlCommand(sql, conn); XmlDocument doc = new XmlDocument(); XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", "UTF-8", null); XmlElement rootNode = doc.CreateElement("inventory"); doc.InsertBefore(dec, doc.DocumentElement); rootNode.SetAttribute("xmlns", "http://seller.marketplace.tests.com/inventory/v1"); rootNode.SetAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); rootNode.SetAttribute("xsi:schemaLocation", "http://sellersupport.domain.test.com/test1/s/schema/inventory/inventory-xml-feed-v1.xsd"); doc.AppendChild(rootNode); XmlElement fbm = doc.CreateElement("inventory"); doc.DocumentElement.PrependChild(fbm); SqlDataReader rdr1 = cmd.ExecuteReader(); while (rdr1.Read()) { XmlElement item = doc.CreateElement("item"); item.Set

how to make a dynamic sitemap

HelloI need to make a sitemap with all the products i have in database.I can make it easly in aspx web file, but is it better if i make it in Web.sitemap file? Would search engines find it?And if is better to make it in Web.sitemap, how can i create siteMapNode for each product i have (and i add) in database?Please help meThank you

Dynamic SiteMap generation with MVC

Hi guys,Is there a way to create a dynamic site map with MVC? Thanks everyone

url routing asp.net 4.0 from xml file or database

does anyone have an example how i would set up the routes table from a databse  i.e can you do something like this i no i should load from a text file created from the save button of my cms page section but dont no how to do that.   rc.MapPageRoute ("page", "page/{Type}", "~/cms.aspx"); // is their some way to load this into the global asx from a text file if so how? "page/{Type}", //URL with parameter "~/cms.aspx"); //Web Form to handle              

The file coloredMenuItems.sitemap required by XmlSiteMapProvider does not exist.


Hi all,

I'm seeing this exception (InvalidOperation Exception from XMLSitemapProvider - trace below) every time I try and access my site. It has worked in the past and this error has just materialised recently, after googling around I see a lot of things referring to permissions on the sitemap file, i've used search to find every occurence of the sitemap on my PC and set 'Everyone' to 'read and execute' and I still have the same issue, I have recycled the app pool and redeployed the site multiple times since I set the permissions.

I have an entry in my web.config:

<add name="ColoredMenu" siteMapFile="_layouts/sitemap/coloredMenuItems.sitemap" type="System.Web.XmlSiteMapProvider" securityTrimmingEnabled="false" />

Is there anything i'm missing? Anything else I could try? I've been toying with this for quite some time and i'd really like my development environment back! >)

Thanks in advance,



Stack Trace:


[InvalidOperationException: The file coloredMenuItems.sitemap required by XmlSiteMapProvider does not exist.]

hiding file-types and resources with Routing



does someone know elegant way to hidde/prevent direct access to some filetypes or web site resources, but that this resources remain accessible from application.

For example that mp3's in Music folder on www.somesite.info cannot be accessed directly via url like http://www.somesite.info/Music/SomeMP3Song.mp3

With routing off course.  I did something, but not very satisfied with it. :( 

Creating a dynamic excel file


Is it possible that i can create a dynamic excel file (destination)


ex, i want to create a Dyanamic Excel destination file with a filename base on the date

this will run on jobs. Is this possible?

11172006.xls, 11182006.xls

Creating Dynamic Sitemap in SharePoint


Hello all,

I have developed a publishing portal in sharepoint.I have a requirement wherein I need to create sitemap for the entire web application.

This should be dynamic, in the sense, whenever we update the contents of any given page in our web application, it should be reflected immediately in the sitemap page. What are the possible ways to achieve this and which is the best possible solution considering the scalability and easy configuration?

Thank you.

Trying to write google video sitemap xsd file


I'm trying to write a gogole video sitemap xsd file, to auto generate video sitemaps.

There is a prefix for the video section <video:video> that I can't seem to get. I get <tns:video> instead

I think it's a namspace issue or I need to add a prefix?

This is my source

<?xml version="1.0" encoding="utf-8" ?>
<!--Created with Liquid XML Studio - FREE Community Edition (http://www.liquid-technologies.com)-->
<xs:schema elementFormDefault="qualified" targetNamespace="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xs="http://www.w3.org/2001/XMLSchema">
            XML Schema for Video Sitemap files. Last Modifed 2010-10-05
  <xs:element name="urlset">
        <xs:element minOccurs="0" maxOccurs="unbounded" name="url">

Dynamic file name in File based report delivery


I am trying to implement a report delivery mechanism which is file based. So the report will be generated in pdf or excel and placed in file share location.  The name of the file needs to be dynamic.  For e.g. : if the report I am running is Daily sales for store 101 with a sales amount of $150 and for the date 03/22. I need to generate a pdf with file name dailysales_101_150_032210.pdf

There are some parameterized report generation scenarios as well. In that case the report name should include the parameters provided. In the above example itself if all the values above are provided as parameter, the report should be generated for the given parameter and the name should contain the parameter.

Has anyone had this requirement and implemented a solution before ? Can this be implemented in a standard subscription & data driven subscription. any custom code is required in order to implement this or can this be done by configuration in SSRS ?

thanks for your help.


Dynamic routing problem when invoking site from remote host.



I have problem described under following link: mvcrouting

Can someone give me some clues how to deal with that ?


Dynamic directory location for "Flat File Source"



I am using a "Flat File Source" to read from a source file. Now I want the directory location to be dynamic because it will change during migration from development to UAT to Production.

Can anyone help me here on this. Ofcourse my intention is not to open and modify the package after migrating into a different environment. Actually I want to store the directory location in a table and want the "Flat File Source" to read the location form that table duing runtime. But not sure whether can I achieve this or not. If yes then how?

Regards - Koushik

URL Routing, How to prevent normal file requests


Now that URL routing is slicker than ever with .NET 4.0 and VS2010, how can I prevent someone from trying to request a normal aspx file. I want all requests to be routed. 

Get dynamic data from log file to track the site usage






How can I track the users who visit the site using Log file. I want to automate the same. We have deployed around 10 websites on the web server which include .net and Flex applications.  I want to make the report of site usage. Would it be possible to do the same using log files?




SSIS 2008: Problem reading dynamic file during execution



I have a SSIS 2008 project that reads a bunch of files from a file (always the same file) from Machine A.
My package is running on Machine B and this is where the information is being imported to, my Reporting DB (sql 2008) is also located in Machine B. 
I have a dynamic log file that stores the execution errors every time the package is executed and its name is made up of the timestamp of when package starts executing. The "DelayValidation" option for this connection is set to "TRUE". When i execute my Package from Visual Studio 2008, it runs without a problem.
The problem is when i deploy my package into SQL Server 2008 and try running it through DTEXEC. I always get the following error:


Error: 2010-11-03 14:57:29.06
   Code: 0xC001401E
   Source: MyImportPackage Connection manager "ImportLog"
   Description: The file name "\\ip-address\d$\Logs\ImportManager\20101103_145726.txt" specified in the connection was not valid.

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend