url rewriting - automatically rewrite URLs in ASP.NET -


i use vs2010,c# develop asp.net web site, customers want me have pages this:

mysite.com/customer (in fact call mysite/customer/default.aspx)

so i've manually created several folders each customer, , inserted default.aspx file in folder users can view customer page typing mysite.com/customer

is there better way performing scenario? don't want have mysite.com/customer1.aspx, want have mysite.com/customer1, there anyway can remove folders (and containing default.aspx files) , generate automatic using customers database?

should use url rewriting? there anyway can create page mysite.com/customer1.aspx, , users can view typing mysite.com/customer1?

i think possible rewrite urls in web.config, don't want manually in web.config pages increase in daily basis

thanks

if really wanted in code , not in config can rewrite path in application_beginrequest using rewritepath method of httpcontext

for example (and simplified example), if aspx in subfolder root go this:

protected void application_beginrequest(object sender, eventargs e) {     if (httpcontext.current.request.path.startswith("/customer"))         httpcontext.current.rewritepath("/customer/whatever.aspx"); } 

note: ignores query string must extracted , re-added , if want case-insensitive, you've have handle too.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -