0
那么我尝试简单ASP.NET URL重写功能不正常
我有一个像含
public partial class WebApi : System.Web.UI.Page
{
[WebMethod]
public static GetImageResult GetRandomImage()
...
我已经添加了以下为“的Global.asax.cs”页一个简单的Web服务(的Application_BeginRequest)
string absolutePath = Request.Url.AbsolutePath.Substring(1);
if (absolutePath.StartsWith("WebApi/", StringComparison.OrdinalIgnoreCase))
{
Context.RewritePath("/WebApi.aspx/" + absolutePath.Substring(7));
}
但asp.net似乎也与此功能不会被调用和JavaScript只是报告“不允许的方法”的问题。
有什么更多我必须做的这项工作?
您应该看看IIS UrlWrite模块。 http://www.iis.net/download/URLRewrite – Phill 2012-03-12 22:44:05
@Phill IIS Rewrite和ASP.net Rewrite有什么区别,它将如何解决我的问题? – Peter 2012-03-13 09:20:29
因为IIS重写模块会在它到达您的应用程序(.NET或PHP或其他)之前重写URL,并且在GUI窗口中设置和测试会更容易,您可以在其中编写正则表达式和示例url来测试用。 – Phill 2012-03-13 11:15:14