开发者

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 ac开发者_StackOverflow社区tually 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...


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 :-)


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.


Here is example how to use new System.Web.Routing within ASP.NET WebForms.

http://deepumi.wordpress.com/2010/02/27/url-routing-in-asp-net-web-forms/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜