views:

111

answers:

3

Hello

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...

A: 

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/

dario-g
this seems to be very time-consuming..should be a lot easier as far as i know..
k0ni
+4  A: 

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

DocV
thanks a lot!genius!
k0ni
but i would be interested in how this affects performance and other things...is this the right way to do it?thx
k0ni
Thats the way to run ASP.NET MVC on IIS6 but all requests even for static content are going through ASP.NET pipeline and performance suffers. You can use mscd.codeplex.com to avoid this.
dario-g
Yep the throughput for static requests will be reduced by ~30%. The best way to avoid this is to partition your site : create two web sites, one with your wildcard mapping without any static resources, and another with your static resources only without a wildcard mapping. Furthermore, its a good pratice with or without a wildcard mapping ;)
JoeBilly
+1  A: 

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.

Wyatt Barnett