【发布时间】:2013-07-19 19:57:47
【问题描述】:
是否可以将即将到来的网址更改为 localhost/test?t=gowtham 到 localhost/test/t/gowtham ?
根据我的理解,我想通过扩展来做到这一点
public class Myhandlers : IHttpHandlerFactory
{
public IHttpHandler GetHandler(HttpContext context, string requestType, string url, string pathTranslated)
{
string s= application.Request.QueryString["t"];
PageParser.GetCompiledPageInstance(url,"/t/"+s, context);
}
}
我是否在正确的道路上,但我无法实现?或者有没有其他办法?
【问题讨论】:
-
你真正想做(或学习)什么?可能有更多标准方法可以做到这一点。
-
只是为了重写所有传入的 url.. 如果应用程序的 url 为 localhost/test,localhost/test/ss.aspx 需要重写为 localhost/test/t/gowtham 和 localhost/test /t/gowtham/ss.aspx
-
考虑使用现有工具,例如IIS url rewrite。
标签: c# .net url-rewriting ihttphandler