Я пишу IHttpModule, чтобы разрешить доступ к дружественному URL-адресу на нашей странице подробностей. Когда пользователь пытается получить доступ к подробной странице с помощью http://xyx.com/hotels/123/ hotel-name.aspx , правило повторной записи будет применяться в методе OnBeginRequest IHttpModule.
Здесь я написал, чтобы изменить путь к «~/DetailPages/DetailPage.aspx», используя Context.RewritePath («~/DetailPages/DetailPage.aspx», «», «Code = 123»), где 123 - это код, взятый из исходного URL ,
Now if original URL does not contain any query string, Detail page is getting invoked. But when user is trying to access http://xyz.com/hotels/123/hotel-name.aspx?show=advance then re-write code will be executed as Context.RewritePath("~/DetailPages/DetailPage.aspx", "", "Code=123&show=advance")
. Here we are getting an error saying "/hotels/123/hotel-name.aspx" page does not existing.
Before & After Calling "Context.RewritePath
" method, I have taken details from Context.Request
object that is given below. Both looks perfect and same if there is no Query string in original URL. But when Original URL contains query string, Inside "Context_Error" (an event to listen any error for this request execution) method, when getting Server.GetLastError()
says "/hotels/123/hotel-name.aspx" page does not existing.
Пожалуйста, обратитесь к описанию трассировки из объекта Context.Request
. Ваша помощь/исходные материалы приветствуются, поскольку я провел 8 часов уже без какого-либо положительного результата.
<Сильный> ---------------------------
До - RewritePath Call
---------------------------
RawUrl: - /Hotels/123/hotel-name.aspx?a=b
AppRelativeCurrentExecutionFilePath: - ~/Отели/123/hotel-name.aspx
CurrentExecutionFilePath: - /Hotels/123/hotel-name.aspx
Params : - a=b&__utma=221736730.1213284380.1356606190.1356674469.1356687004.4.....(Windows+NT+5.1%3b+rv%3a7.0.1)+Gecko%2f20100101+Firefox%2f7.0.1
Путь: - /Hotels/123/hotel-name.aspx
PhysicalPath: - D: \ AppRoot \ Отели \ 161 \ hotel-name.aspx
Url : - http://xyz.com/Hotels/123/hotel-name.aspx?a=b
<Сильный> ---------------------------
После - RewritePath Call
---------------------------
RawUrl: - /Hotels/123/hotel-name.aspx?a=b
AppRelativeCurrentExecutionFilePath: - ~/DetailPages/DetailPage.aspx
CurrentExecutionFilePath: - /DetailPages/DetailPage.aspx
Params : - Code=123&a=b&__utma=221736730.1213284380.1356606190.1356674469.1356687004.4.....(Windows+NT+5.1%3b+rv%3a7.0.1)+Gecko%2f20100101+Firefox%2f7.0.1
Путь: - /DetailPages/DetailPage.aspx
PhysicalPath: - D: \ AppRoot \ DetailPages \ DetailPage.aspx
Url : - http://xyz.com/DetailPages/DetailPage.aspx?Code=123&a=b
--- Server.GetLastError
- Trace - Внутри события ошибки IHttpModule -
RawUrl: - /Hotels/123/hotel-name.aspx?a=b
AppRelativeCurrentExecutionFilePath: - ~/Отели/123/hotel-name.aspx
CurrentExecutionFilePath: - /Hotels/123/hotel-name.aspx
Params : - a=b&__utma=221736730.1213284380.1356606190.1356674469.1356687004.4....(Windows+NT+5.1%3b+rv%3a7.0.1)+Gecko%2f20100101+Firefox%2f7.0.1
Путь: - /Hotels/123/hotel-name.aspx
PhysicalPath: - D: \ AppRoot \ Отели \ 161 \ hotel-name.aspx
Url : - http://xyz.com/Hotels/123/hotel-name.aspx?a=b
Error Message
The file '/Hotels/123/hotel-name.aspx' does not exist.
Stack Trace
at System.Web.UI.Util.CheckVirtualFileExists(VirtualPath virtualPath)
at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)
at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)
at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean noAssert)
at System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp, Boolean noAssert)
at System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath)
at System.Web.UI.PageHandlerFactory.System.Web.IHttpHandlerFactory2.GetHandler(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath)
at System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig)
at System.Web.HttpApplication.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Может ли кто-нибудь узнать, что может быть проблемой?
Заранее спасибо.