Home » Asp.net

Do I need to set up anything in IIS for URL Routing in my ASP.NET app?

I'm using IIS 7 with Windows Server 2008 and the app doesn't even run when I open it up on localhost. May be because I transfered the app file from Windows Server 2000? Any helps will be appreciated!


6 Answers Found


Answer 1



Answer 2


What is you ASP.NET version and database? How did you deploy your application on the new hosting server?




Answer 3

Sorry for a slow response, here is the error:


HTTP Error 500.24 - Internal Server Error An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode.

Detailed Error Information
Module Notification Handler Error Code
Requested URL Physical Path Logon Method Logon User
Not yet determined
Not yet determined

Most likely causes: system.web/identity@impersonate is set  to true.

Things you can try: If the application supports it, disable client impersonation. If you are certain that it is OK to ignore this error, it can be disabled by setting system.webServer/validation@validateIntegratedModeConfiguration to false. Move this application to an application pool using Classic .NET mode - for example, %SystemRoot%\system32\inetsrv\appcmd set app  "Default Web Site/" /applicationPool:"Classic .NET AppPool" (You can set "Classic .NET AppPool" to the name of another application pool running in Classic managed pipeline mode)

Answer 4

Where do I go to check ASP.NET version? We are using MS Server (R) 2008 Standard Build 6002. We haven't deployed anything on the new hosting server this asp  app used to work on our intranet(MS Server 2000).


Answer 5

In IIS -> Sites -> yourdomain.com -> Basic Settings -> check asp.net version

IIS by default has 2 application pools for Classic & Integrated mode.

According to instruction in the error, you should switch website to asp.net classic mode.


Answer 6

It shows .NET Framework Version 2.0 and I have changed to classic mode my asp  app still doesn't show up. Cry 



Hello, this is my first post :). I have the following issue with ASP.NET 4 VB.NET with MVC Framework 2 installed. 

The code in GLOBAL.ASAX to rename images like "domain.com/images.aspx?id=1&ref=5&size=500" is the following:

  Private Sub RegisterRoutes(ByVal Routes As RouteCollection)
    Routes.MapPageRoute("Image", "images/{Ref}/{Size}/{Id}/{Title}", "~/Image.aspx", False, New RouteValueDictionary(New With {.Title = "", .Id = "", .Size = "", .Ref = ""}))
  End Sub
  Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
  End Sub

It works OK, because now I can open the images with this format: "domain.com/images/5/500/1/1/this-is-my-seo-filename".

But like you can see, the image file do not contain the ".jpg" to the end of the url. I tried to add in GLOBAL.ASAX some code like:

Routes.MapPageRoute("Image", "images/{Ref}/{Size}/{Id}/{Title}.jpg", "~/Image.aspx", False, New RouteValueDictionary(New With {.Title = "", .Id = "", .Size = "", .Ref = ""})) 

This code convert the URL to "domain.com/images/5/500/1/1/this-is-my-seo-filename.jpg" but when I open the url in the browser I received "HTTP ERROR 404 Not Found".

How can I use the extension ".jpg" or whatever extension, in a asp.net routing url with ASP.NET 4 VB.NET? Thank you.


hi friends

i have a web project and that have over 150 pages

now if i used URL Routing in this project speed and performance less or no?






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?


//URL with parameter


//Web Form to handle









I have a requirement to add specific functionality to an asp.net mvc2 web site to provide addtional SEO capability, as follows:

The incoming URL is plain text, perhaps a containing a sentence as follows

"http://somesite.com/welcome-to-our-web-site" or "http://somesite.com/cool things/check-out-this-awesome-video"

In the MVC pipeline, I would like to take this URL, strip off the website name, look up the remaining portion in a database table and call an appropriate controller/view based on the content of the data in the table. All controllers will simply take a single parameter bieng the unique id from the lookup table. A different controller may be used depnding on different urls, but this must be derieved from the database.

If the url cannot be resolved a 404 error needs to be provided, if the url is found but obsolete then a 302 redirect needs to be provided.

Where the url is resolved it must be retained in the browser address bar.

I have had a look at the routing model, and custom routing and can't quite work out how to do it using these, as the controller would not be predefined, based on a simple route. I am also unsure of what to do to provide 404, 302 back to the headers also. Perhpas I need a custom httpmodule or similar but going there went beyond my understanding.

This must be possible somehow... we did it years ago in Classic ASP. Can anyone help with some details on how to achieve this?


HI there,

I have implemented URL Routing in Asp.net 4.0 application, when i try to run it on windows server 2003 R2 server with IIS 6.0. the application works fine but without routing, whereas routing works fine on every other server.


is there any thing else i can do??


HI there,

I have implemented URL Routing in Asp.net 4.0 application, when i try to run it on windows server 2003 R2 server with IIS 6.0. the application works fine but without routing, whereas routing works fine on every other server.


is there any thing else i can do??


I have implemented URL Routing in Asp.net 4.0 application, when i try to run it on windows server 2003 R2 server with IIS 6.0. the application works fine but without routing, whereas routing works fine on every other server.


is there any thing else i can do??


It seems that Pagemethods don't work well when used with ASP.NET 4 / IIS 7 URL Rewriter.

(see also thread on IIS Forum http://forums.iis.net/p/1171236/1955591.aspx#1955591)

Is anyone aware of any work around from an ASP.NET / AJAX side?

Is there any trick or specific configuration to make this work?

Thx in advance



Hello I have a webapp called Reporting with this route:

RouteTable.Routes.Add("ViewerRoute", new Route
                 , new AppCode.RoutingHandler("~/ReportViewer.aspx")

Everything works fine if i publish to this path http://mysite/myReportingApp/

Now i want to publish to a this path http://intrasite1/Reports/myReportingApp/ but the routing is not working anymore.

Any suggestion? Thank you


Hello! I have problem with my hosting company.
They set virtual memory limit on iis, and says, than my web site exceed limit - 96 Mb.

I testing in memory profiler and knew, that is not right.

I made a simple test.  I create simple project (frameworkk 3.5) from one page with text "Hello World" and attached this site
to my IIS6.

And I see, if I set the  parameter maximum virtual memory is less than 500 Mb, then
I get error
In event viewer:
"A worker process with process id of '5848' serving application pool 'DefaultAppPool' has requested a recycle because it reached its virtual memory limit."

If I set parameter maximum virtual memory to 500 Mb and set parameter maximum used memory to 96 Mb my site work normally.


It seems, that asp.net takes a 500 mb memory in reserve.


 I just created a small site with form authentication with route handling.  Without forms authentication, the pages route just fine.  With forms, it returns back to the login page as it is not one of my allowed locations specified in my web.config file.


I know I probably need to write a custom route handler.  Does anyone have an example I can follow for this?  Thanks.



We are running SQL Server 2008 R2 in Integrated Security mode and our reports were built with Report Builder 3.0.

Our users access the reports through an ASP.NET IIS web application. The web application recovers the user's login "AD\UserName" that we use to determine which reports he or she can see.  The reports are displayed on the web page using

<img src="http://Server/ReportServer/Pages/ReportViewer.aspx?/TestReport&rs:Format=IMAGE&rc:OutputFormat=png">

Apparently this access method sends the user's credentials "AD\UserName" to Report Server for determining access permissions, instead of using a generic IIS Admin Service logon. 

Currently in Report Manager we've added permissions to everyone to see all reports "AD\Domain Users", plus "BUILTIN\Administrators".  This is not ideal.  We want to find a solution without "AD\Domain Users", just using the IIS Admin Service account.

We want to prevent our users from accessing the reports directly through Report Manager, for example by finding the URL on the web page and navigating to it. We want to manage access to the reports strictly through the web application.

Is there a way to force access through the web application only, using the IIS Admin Service's login instead of the user's credentials?  We would like to remove "AD\Domain Users" from Report Manager and force all access through the web application's IIS login.

Can you help us set up the permissions correctly between the web application and Report Server?

Thanks for your help!

Best regards, Christopher Sorensen



I have a problem with setting up SQL Server 2008 for an ASP.NET website on IIS 6.0.

I allways recieve the error message: "Login failed for user 'BADER-7C554BD89\ASPNET'. "

What I should do?

Please, I need your help,





So, all I have done is created a new ASP.NET MVC 2 site in VS 2010. It is the complete default site, nothing added/removed. It opens up in a browser fine and runs when I go to debug it, however I want to set it up in IIS7 so I can test it without having to do that.

I got really frustrated with failed attempts so at the moment I don't even have the 'Default Web Site' under Sites in my IIS7. Nothing is under 'Sites'. Can anyone just go step by step for me at how to set this up and run it in my browser so I can note it down for the future?



We have recently migrated one of our legacy websites (classic ASP) to ASP.Net 4.0. I have already created a RegisterRoutes() in Global.asax (as per http://weblogs.asp.net/scottgu/archive/2010/01/05/asp-net-4-seo-improvements-vs-2010-and-net-4-0-series.aspx). I am concerned about SEO rankings and link breakages with external sites linking to old site.

 Ideally, I will like to:

 Load all the routes from an XML file within RegisterRoutes() --> As there are 100's of pages with no naming convention followed. We have already created mappings within an excel spread sheet which can easily be exported to XML.Action Permanent redirects from within RegisterRoutes() --> to avoid having landing page(s) performing Redirects like Response.RedirectPermanent() and Response.RedirectToRoutePermanent.

Has anyone run into a similar situation? Is there a better way of handling this situation?

Your help is much appreciated.

Kind regards,



Looking at the asp.net v4 URL Routing it's easy to see how to access routing data from basically anywhere in the app. 

Via: Page.RouteData.Values["blah"]

Unfortuantely the Route data always is blank by the time i hit the page on my v 3.5 implementation of routing.  I was wondering if there was any way to either pass the route values to the final page so i can use them there - i really don't want additional logic in my handler file and i have loads of Routes and don't want many RouteHandlers.

Right now im left to examining URL Segments (because of how i re-write the url's) and that is a bit messy.






I have this url working in my code:


I want to change my url to NOT to include the home/index (<controller>/<action>).

ie, it should work like



My current Global.asax entry is like:

   "Default",// Route name 
   "{controller}/{action}/{parameter1}/{parameter2}/{parameter3}/{year}/{parameter4}",// URL with parameters 
   new{ controller ="Home", action ="Index", parameter1="", parameter2="", parameter3="", parameter4=""}// Parameter defaults 
please let me knowgbhatnagar



When I run my website on local server asp.net routing works very well, but when I deploy it on a remote server ( asp 4.0 integrated pipeline ) it always returns with 404 error.

My url route is very simple, a stored procedure gets image's id and then displays it.


public class Global : System.Web.HttpApplication

        protected void Application_Start(object sender, EventArgs e)

        protected void Session_Start(object sender, EventArgs e)


        protected void Application_BeginRequest(object sender, EventArgs e)


        protected void Application_AuthenticateRequest(object sender, EventArgs e)


        protected void Application_Error(object sender, EventArgs e)


        protected void Session_End(object sender, EventArgs e)


        protected void Application_End(object sender, EventArgs e)


        void RegisterRoutes(RouteCollection routes)



 protected void Page_Load(object sender, EventArgs e)
            var route = Page.RouteData.Values["id"];
            if (route == null)
                routeParameter = 2;
                routeParameter = Convert.ToInt32(route);
protected string routeParameter;


If anyone is interested, I have figured out how to do CakePHP style prefix routing with ASP.NET MVC 2.

Feel free to post changes or suggestions!  I have spent hours combing google to try to fit these peices together.

(Please excuse the  pasted code,  the code inserter was messing up the line breaks.)

First of all if you are not familiar with cakephp, it is an MVC framework for PHP that is similar to Rails.

It has a concept of prefix routing (sometimes called admin routing).  What this does is turn a route like this:  /admin/controller/action  into  controller::admin_action.

It basically extracts the 'admin' part out of the Url and prefixes the action name with it.  This is beneficial because it allows you to have separate actions in the same controller that are targeted for an administrative account, or any other use you can think of.  By using the actionlink generator, if you do not specify a 'prefix' it will assume that you are using the same prefix.  This is great because now you can use partial views for navigation in both views 'admin_index' and 'index'  and it will remember which prefix you are using.  (DRY)  ex: <%=html.actionlink('name','someaction')%>  if used in an admin view will generate a link to admin_someaction. 

With .NET MVC 2 there is a new concept called 'Areas' that allows you to separate your application into sections for ease of development.  (Similar to CakePHP plugins).  But this does not quite achceive the same thing.  It requires you to have separate controllers.  This is good  for different purposes.

Anyway,  My implementation will support both 'Areas' and prefix routing.  However the url will look like this:  /area/controller/prefix/action  or just simply: /controller/prefix/action   for the main application.  It will do the same thing as the cakephp routing but the route elements will be in a different order.

First we need to create a route handler class that will support this 'prefix' concept:



Imports System.Web

Imports System.Web.Mvc

Imports System.Web.Routing

Namespace Util.Routing

Public Class PrefixRouteHandler

Implements IRouteHandler

Public Function GetHttpHandler(ByVal requestContext As System.Web.Routing.RequestContext) As System.Web.IHttpHandler Implements System.Web.Routing.IRouteHandler.GetHttpHandler

If (requestContext.RouteData.Values.ContainsKey("prefix")) Then

' Prefix is present

Dim prefix As String = requestContext.RouteData.Values("prefix")

If Not String.IsNullOrEmpty(prefix) Then

' Prefix is not empty

Dim action = requestContext.RouteData.Values("action")

If action Is Nothing Then

action = "index"

End If

' Rename the action to 'prefix_action'

requestContext.RouteData.Values("action") = prefix & "_" & action

End If

End If

Return New MvcHandler(requestContext)

End Function

End Class

End Namespace


This handler basically just looks at the route values and extracts a 'prefix' out. It then renames the action to 'prefix_action' before handing control to the default Mvc Handler.

Now open up your global.asax and add a new route definition to handle the prefix routing.  ( I added a constraint so that it will pick up the prefix if it is either 'admin' or 'manager'


Imports Util.Routing

Public Class MvcApplication

Inherits System.Web.HttpApplication

Shared Sub RegisterRoutes(ByVal routes As RouteCollection)


routes.IgnoreRoute("{*favicon}", New With {.favicon = "(.*/)?favicon.ico(/.*)?"})


routes.Add("Main_Prefix", _

New Route("{controller}/{prefix}/{action}/{id}", New PrefixRouteHandler()) _

With {.Constraints = New RouteValueDictionary(New With {.prefix = "(admin|manager)"}), _

.Defaults = New RouteValueDictionary(New With {.controller = "Home", .action = "Index", .id = ""}), _

.DataTokens = New RouteValueDictionary(New With {.namespaces = New String() {"MyApplication.Controllers"}})})

' MapRoute takes the following parameters, in order:

' (1) Route name

' (2) URL with parameters

' (3) Parameter defaults

routes.MapRoute( _

"Default", _

"{controller}/{action}/{id}", _

New With {.controller = "Home", .action = "Index", .id = ""}, _

Nothing, _

New String() {"MyApplication.Controllers"} _


End Sub

Sub Application_Start()




End Sub

End Class


As you can see, i added a route called 'Main_Prefix'   It tells the system to use the 'PrefixRouteHandler' for the request which will handle the prefix.

* I also added a namespace into the datatokens.  This is because I may have controllers with the same name in different areas.  It tells the system to look in that namespace for the controller. And not to be confused about the other controllers with the same name.

This will pick up the prefix routes and deal with them accordingly.

Part 2:  Areas support.

Now when you add a new 'Area' to your application.  To support this same feature in that area,  Add a similar route definition to your AreaRegistration Class.

(My area was called 'Budget')  So I want to be able to do this:  /budget/controller/prefix/action

Here is my AreaRegistration Class:


Imports Util.Routing

Namespace Areas.Budget

Public Class BudgetAreaRegistration

Inherits AreaRegistration


Public Overrides ReadOnly Property AreaName() As String


Return "Budget"

End Get

End Property


Public Overrides Sub RegisterArea(ByVal context As System.Web.Mvc.AreaRegistrationContext)


context.Routes.Add("Budget_Prefix", _

New Route("{area}/{controller}/{prefix}/{action}/{id}", New PrefixRouteHandler()) _

With {.Constraints = New RouteValueDictionary(New With {.area = "Budget", .prefix = "(admin|manager)"}), _

.Defaults = New RouteValueDictionary(New With {.controller = "Home", .action = "Index", .id = ""}), _

.DataTokens = New RouteValueDictionary(New With {.area = "Budget", .Namespaces = New String() {"MyApplication.Areas.Budget.Controllers"}})})


context.MapRoute( _

"Budget_default", _

"{area}/{controller}/{action}/{id}", _

New With {.controller = "Home", .action = "Index", .id = ""}, _

New With {.area = "Budget"}, _

New String() {"MyApplication.Areas.Budget.Controllers"} _



End Sub

End Class

End Namespace


As you can see, I added the route: 'Budget_Prefix'

It has two constraints: 

{area} must be 'Budget' -- this stops it from interfering with other routes.{prefix} must be either 'admin', or 'manager'

* this is important!:

I added the 'area' token to the 'DataTokens'  - This will ensure that the new mvc 2 areas support will be able to resolve your view name!  It must be set to the name of your Area. I also added the namespace for the same reasons as before.

Also, I changed the default route for this area to include the {area} token.  Im not sure if this is necessary but it works.

WIth these changes you will be able to do these routes:

/controller/action/id               -   resolves to :     controller.action(id)
/area/controller/action/id           - resolves to:        (area) controller.action(id)/controller/prefix/action/id         - resolves to:         controller.prefix_action(id)/area/controller/prefix/action/id - resolves to:       (area) controller.prefix_action(id)

I hope my ramblings will help someone who is trying to figure this out!


 I have set up page routing so that if I go to www.mysite.com/products/specificcategory it should take me to www.mysite.com/products.aspx and I can access whatever specificproduct was entered into the URL with code like:

 If Page.RouteData.Values("categoryname") Is Nothing Then
            literalJustTesting.Text += "no category specified"
            literalJustTesting.Text += Page.RouteData.Values("categoryname").ToString()
        End If

This works perfectly as long as a URL ending in .aspx is entered, such as www.mysite.com/products/somecategory.aspx but if the URL doesn't end in ".aspx" then I just get the default error page:

Server Error 404 - File or directory not found.

I can't seem to find where to turn off this default error page so the page routing can work as it is supposed to. I am new to IIS 7 but have experience with IIS6. Seems like this should be easy but I am stuck. Any suggestions appreciated.




<< Previous      Next >>

Microsoft   |   Windows   |   Visual Studio   |   Sharepoint   |   Azure