2

I'm using IIS URL Rewrite to rewrite "/about" to "/home/about".

If I use any helper that generates a relative url like "@Url.Content" or "@using(Html.BeginForm(Action, Controller)", it gives me an exception:

System.Web.HttpException: Cannot use a leading .. to exit above the top directory.

It's very easy to reproduce the exception and I'm very frustated that I haven't found a solution yet. Any ideas? Thanks in advance.

Stack Trace:

[HttpException (0x80004005): Cannot use a leading .. to exit above the top directory.]
System.Web.Util.UrlPath.ReduceVirtualPath(String path) +11495983
System.Web.Util.UrlPath.Reduce(String path) +171
System.Web.VirtualPath.Combine(VirtualPath relativePath) +214
System.Web.VirtualPathUtility.Combine(String basePath, String relativePath) +158
System.Web.Mvc.PathHelpers.GenerateClientUrlInternal(HttpContextBase httpContext, String contentPath) +385
System.Web.Mvc.UrlHelper.GenerateUrl(String routeName, String actionName, String    controllerName, RouteValueDictionary routeValues, RouteCollection routeCollection,      RequestContext requestContext, Boolean includeImplicitMvcValues) +257
MvcSiteMapProvider.DefaultSiteMapNodeUrlResolver.ResolveUrl(MvcSiteMapNode mvcSiteMapNode, String area, String controller, String action, IDictionary2 routeValues) +1034
MvcSiteMapProvider.MvcSiteMapNode.get_Url() +323
MvcSiteMapProvider.AuthorizeAttributeAclModule.IsAccessibleToUser(IControllerTypeResolver controllerTypeResolver, DefaultSiteMapProvider provider, HttpContext context, SiteMapNode node) +135
MvcSiteMapProvider.DefaultAclModule.IsAccessibleToUser(IControllerTypeResolver controllerTypeResolver, DefaultSiteMapProvider provider, HttpContext context, SiteMapNode node) +216
MvcSiteMapProvider.DefaultSiteMapProvider.IsAccessibleToUser(HttpContext context, SiteMapNode node) +349
MvcSiteMapProvider.Web.Html.MenuHelper.BuildModel(MvcSiteMapHtmlHelper helper, SiteMapNode startingNode, Boolean startingNodeInChildLevel, Boolean showStartingNode, Int32 maxDepth, Boolean drillDownToCurrent) +361
MvcSiteMapProvider.Web.Html.MenuHelper.Menu(MvcSiteMapHtmlHelper helper, String templateName, SiteMapNode startingNode, Boolean startingNodeInChildLevel, Boolean showStartingNode, Int32 maxDepth, Boolean drillDownToCurrent) +87
MvcSiteMapProvider.Web.Html.MenuHelper.Menu(MvcSiteMapHtmlHelper helper, SiteMapNode startingNode, Boolean startingNodeInChildLevel, Boolean showStartingNode, Int32 maxDepth, Boolean drillDownToContent) +40
MvcSiteMapProvider.Web.Html.MenuHelper.Menu(MvcSiteMapHtmlHelper helper, Boolean startFromCurrentNode, Boolean startingNodeInChildLevel, Boolean showStartingNode) +86
ASP._Page_Views_Shared__SfMaster_cshtml.Execute() in c:\webmaster\projects\jclcorp\jclcorpmvc\Views\Shared\_SfMaster.cshtml:22
System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +280
System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +104
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +173
System.Web.WebPages.WebPageBase.Write(HelperResult result) +89
System.Web.WebPages.WebPageBase.RenderSurrounding(String partialViewName, Action1 body) +234
System.Web.WebPages.WebPageBase.PopContext() +222
System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +384
System.Web.Mvc.<>cDisplayClass1c.b19() +33
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter,    ResultExecutingContext preContext, Func1 continuation) +798756
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList1 filters, ActionResult actionResult) +265
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +798832
System.Web.Mvc.Controller.ExecuteCore() +159
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +335
System.Web.Mvc.<>cDisplayClassb.b5() +62
System.Web.Mvc.Async.<>cDisplayClass1.b0() +20
System.Web.Mvc.<>cDisplayClasse.bd() +54
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +469
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +375

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.225
PhillyNJ
  • 3,859
  • 4
  • 38
  • 64
Joao Leme
  • 9,598
  • 3
  • 33
  • 47
  • This helped me: http://stackoverflow.com/questions/3826299/asp-net-mvc-urlhelper-generateurl-exception-cannot-use-a-leading-to-exit-ab#answer-9546561 – s1mm0t Apr 03 '12 at 16:18
  • thansk @s1mm0t. Has it worked for you without flaws? I gave up on url rewrite with mvc and instead doing it on the routing together with an ActionFilterAttribute -> RemoveDuplicateContentAttribute (http://weblogs.asp.net/imranbaloch/archive/2011/12/19/solving-duplicate-content-issue-in-asp-net.aspx) – Joao Leme Sep 20 '12 at 12:03

2 Answers2

0

I am posting this in hopes that someone else may find it helpful. I received this error when using url rewrites in iis 7. The error only occurred in Safari and Chrome. The solution was to add the folder App_Browsers and add a new .browser file to your solution. In the file add this snippet:

<browser refID="safari1plus">
 <controlAdapters>
  <adapter controlType="System.Web.UI.WebControls.Menu" adapterType="" />
 </controlAdapters>
</browser>
PhillyNJ
  • 3,859
  • 4
  • 38
  • 64
0

try this solution. It helped me.

creating extra rule in route config solved problem

Community
  • 1
  • 1
aleha_84
  • 8,309
  • 2
  • 38
  • 46