Routing was introduced with ASP.NET 4.0, and it works like a charm. However, to make routing work properly, most of us would add a setting to web.config
Without this, IIS would only run managed modules for known ASP.NET resources (for example, .aspx files). If we, for example, request the url http://www.luminowebdesign.no/default.aspx, then IIS will see that this is a know ASP.NET resource and process it correctly. However, if we use routing and request http://www.luminowebdesign.no/forsiden - which in our system is the same page, then IIS will not understand that it should process this page. The "runAllManagedModulesForAllRequests=true" would fix this, as IIS now will run all managed modules for every single request - but the fix comes at at performance cost.
An alternative to the above setting, is to specify the managed modules we want to run. Obviously, we want to run the UrlRoutingModule as specified below. However, it is also now easy to introduce potential bugs, since IIS will not cause the other managed modules to fire and commonly used functionality might suddenly disappear. For example, if we did not specify SessionStateModule in the config setting below, then any pages using routing would get an exception when trying to use Session.
<remove name="UrlRoutingModule-4.0" />
<add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" />
<add name="Session" type="System.Web.SessionState.SessionStateModule" preCondition=""/>
There might be other modules you want to have running, such as Forms Authentication, Windows Authentication, as so on.
Happy Routing :)
Here's a short little BLOGGER BIO to tell you a little bit about my background - and why I chose to get into programming and SEO.
I grew up in Norway, but went to school in the U.S. I have a degreen in computer science from Arizona State University. After graduating I moved back to Norway where I got a job working at Norwegian Data and later IBM. I went on to do a Masters of Management at BI in Oslo. After several years as a senior executive at IBM I decided to start my own company, Apropos Internet. In 2004 I started Virosafe Norway, a company that imports and distributes data security products, and now I am CEO of Lumino as well.
It's always been essential for me to stay up to date on the latest trends and developments in technology - not only to stay current as a programmer, but also to ensure my success as an entrpreneur. Lumino blog articles contain a variety of topics that have been useful for my own businesses - perhaps you will find them useful as well.
© powered by Lumino