使用asp.net重写URL。有没有配置需要? [英] Url rewriting with asp.net. is there a configuration needed?

查看:187
本文介绍了使用asp.net重写URL。有没有配置需要?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的项目中启用重写的网址。
这篇文章中描述的很好: urlrewriting通过scottgu
当它运行在localhost上运行非常好,但一旦我上传到我的主机(.net 3.5),它doesn工作!我总是被重定向到一个404页面!



是否需要配置来启用这个?
as scottgu说不,但我不知道为什么它不工作...



感谢



// UPDATE 2.09.2010



有没有一个方法来启用路由或重写没有iis7或安装模块像ISAPI Rewrite的能力服务器?
看起来我有一个坏的asp.net主机...

解决方案

您的ASP.NET开发服务器上的网站。该服务器设置为捕获所有请求(*。*)并通过ASP.NET管道运行它们。

另一方面,II6配置为只发送一些请求(即* .aspx,* .asmx,* .ashx)通过ASP.NET管道。所以,如果你试图捕获一个像/ my / fine / url这样的url的请求,它不会被传递给ASP.NET处理程序,因此不会被重写。



您可以在网站的应用程序配置中更改此配置:


  1. 打开IIS管理器并右键单击网站,

  2. 在主目录标签上,点击配置...按钮。
  3. 通配符应用程序映射。
  4. 在Executable:中插入aspnet_isapi.dll的路径,在我的例子中为C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll注意:此路径可能在您的服务器上不同)。

  5. 请务必取消选中验证该文件存在

  6. 点击确定!

因此!所有您的请求现在应该被定向到ASP.NET处理程序,因此被捕获在您的URL重写器,无论扩展名。



但我必须承认,我有点不确定这将如何影响您的网站上的性能,通过ASP.NET处理程序路由所有静态文件,CSS,图像等请求。也许别人在那里有话要说。



/ Dennis: - )


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

解决方案

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

这篇关于使用asp.net重写URL。有没有配置需要?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆