Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Url rewriting with asp.net. is there a configuration needed?

I'm trying to enable rewrited urls in my project. it's very good described in this post: urlrewriting by scottgu It works very well when im running it on localhost, but as soon as i upload it to my host (.net 3.5), it doesn't work! i always get redirected to a 404 page!

Is there a configuration needed to enable this? as scottgu says no, but i don't find out why it's not working...

thanks

// UPDATE 2.09.2010

Is there actually a way to enable routing or rewriting without having iis7 or the ability to install a modul like ISAPI Rewrite on the server? Looks like i got a bad asp.net host...

like image 672
k0ni Avatar asked Aug 30 '10 08:08

k0ni


2 Answers

In your localhost environment you are probably running the website on your ASP.NET Development server. That server is set up to capture all request (* . *) and run them through the ASP.NET pipeline.

II6 on the other hand, is configured to only send some requests ( ie *.aspx, *.asmx, *.ashx) through the ASP.NET pipeline. So if you are trying to catch a request for an url like "/my/fine/url" that will never be passed to the ASP.NET handler, and thus not rewritten.

You can change this configuration in the Application configuration for the website:

  1. Open IIS Manager and right-click on the website, choose Properties
  2. On the tab "Home Directory", click "Configuration..." button.
  3. Click "Insert..." button to insert a Wildcard application map.
  4. In "Executable:" insert path to aspnet_isapi.dll, in my case C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll (note: this path may differ on you server).
  5. Remember to uncheck "Verify that file Exists"
  6. Click OK!

And so! All your requests should now be directed to the ASP.NET handler and hence caught in your URL rewriter, regardless of extension.

But I must admit that I'm a bit unsure as to how this will affect performance on you site, routing all requests for static files, css, images etc through the ASP.NET handler. Maybe someone else out there has something to say about that.

/Dennis :-)

like image 142
Dennis Skantz Avatar answered Nov 15 '22 09:11

Dennis Skantz


There are two ways to get the extensionless routes in IIS6:

a) ISAPI rewrite or other ISAPI url rewriter
b) Use a wildcard mapping to aspnet_isapi.dll

See this blog post for detailed instructions.

like image 35
Wyatt Barnett Avatar answered Nov 15 '22 08:11

Wyatt Barnett