ASP.NET WebForms Domain Routing

I saw a cool implementation of ASP.NET MVC Domain Routing.
Source: http://blog.maartenballiauw.be/post/2009/05/20/ASPNET-MVC-Domain-Routing.aspx

Can this be done in ASP.NET WebForms 4.0?

+7
source share
4 answers

Given the fact that the Route class is not specific to MVC applications and can be easily used in the context of a simple ASP.NET WebForms project, the DomainRoute class you are associated with should work fine in this context.

There must be a simple enough enterprise to prove.

+1
source

The answer to your question is yes. It is actually quite simple. You can try the DomainRoute class or just write your own URL rewrite module and be nice. But basically you would use something like this:

http://www.gutgames.com/post/Url-Rewriting-in-ASPNet.aspx

And instead of the path, you should use the Url property and parse it however you want. Or you can simply use an open source project as follows:

http://sharedhostingsplittr.codeplex.com/

And change it a little if necessary.

+1
source

Short answer: yes, you can use routing in WebForms. Take a look at the System.Web.Routing .

In your Application_Start in your Global.asax, you can configure routes based on text or regular expressions.

0
source

Yes, add the Global.ascx file to your project and add the function written by me to it.

  public static void UrlRouting(RouteCollection RC, string RoutName, string routeUrl, string Page) { RC.MapPageRoute(RoutName, routeUrl, Page); } after this inside Application_Start event on global.ascx file call that function like UrlRouting(RouteTable.Routes, "index", "Home", "~/index.aspx"); 

and then call it the route URL ~ / Home "> Home Note: Remember to call ResolveUrl with your URL, otherwise it cannot be called and your images and jquery, js paths should also have ResolveUrl as" / "> otherwise this jquery will not work and images will not be displayed hope this helps

0
source

All Articles