Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

500 error on Custom Error Pages #304

Closed
jamierytlewski opened this issue Mar 28, 2014 · 6 comments
Closed

500 error on Custom Error Pages #304

jamierytlewski opened this issue Mar 28, 2014 · 6 comments

Comments

@jamierytlewski
Copy link

I've created custom error pages and they use the same layout/template as all my other pages. I use @Html.MvcSiteMap().SiteMapPath() to get sitemap path on each page.

Recently (not sure which version), but now I'm getting the error:

Invalid URI: The format of the URI could not be determined.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.UriFormatException: Invalid URI: The format of the URI could not be determined.

[UriFormatException: Invalid URI: The format of the URI could not be determined.]
   System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind) +6676197
   System.Uri..ctor(String uriString, UriKind uriKind) +21
   MvcSiteMapProvider.Matching.UrlKeyBase.SetUrlValues(String relativeOrAbsoluteUrl) +101
   MvcSiteMapProvider.Matching.RequestUrlKey..ctor(String relativeOrAbsoluteUrl, String hostName, IUrlPath urlPath) +67
   MvcSiteMapProvider.Matching.UrlKeyFactory.Create(String relativeOrAbsoluteUrl, String hostName) +35
   MvcSiteMapProvider.SiteMapChildStateFactory.CreateUrlKey(String relativeOrAbsoluteUrl, String hostName) +14
   MvcSiteMapProvider.SiteMap.FindSiteMapNodeFromUrl(String relativeUrl, String relativePath, String hostName, IHttpHandler handler) +23
   MvcSiteMapProvider.SiteMap.FindSiteMapNodeFromPublicFacingUrl(HttpContextBase httpContext) +75
   MvcSiteMapProvider.SiteMap.FindSiteMapNode(HttpContextBase httpContext) +20
   MvcSiteMapProvider.RequestCacheableSiteMap.FindSiteMapNodeFromCurrentContext() +79
   MvcSiteMapProvider.SiteMap.get_CurrentNode() +15
   MvcSiteMapProvider.Web.Html.SiteMapPathHelper.SiteMapPath(MvcSiteMapHtmlHelper helper, String templateName, String startingNodeKey, SourceMetadataDictionary sourceMetadata) +45
   MvcSiteMapProvider.Web.Html.SiteMapPathHelper.SiteMapPath(MvcSiteMapHtmlHelper helper) +45
   ASP._Page_Views_Shared__Layout_cshtml.Execute() in c:\Users\rytlewski\Documents\git\DEC\DEC\Views\Shared\_Layout.cshtml:92
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +198
   System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +104
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +90
   System.Web.WebPages.<>c__DisplayClass7.<RenderPageCore>b__6(TextWriter writer) +232
   System.Web.WebPages.HelperResult.WriteTo(TextWriter writer) +10
   System.Web.WebPages.WebPageBase.Write(HelperResult result) +80
   System.Web.WebPages.WebPageBase.RenderSurrounding(String partialViewName, Action`1 body) +63
   System.Web.WebPages.WebPageBase.PopContext() +267
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +98
   System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +235
   System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +107
   System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +291
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +56
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +420
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +52
   System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +173
   System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +100
   System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +27
   System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +13
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +36
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +54
   System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +39
   System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller) +12
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +28
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +54
   System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +29
   System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
   System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +21
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +36
   System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +54
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +31
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9690164
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
@NightOwl888
Copy link
Collaborator

Version 4.6.1 added full support for absolute URLs, so the URL parsing was changed quite a bit for explicit URLs. The most likely cause is that you are setting the Url property explicitly to a format that is not supported.

The only formats that are officially supported are:

Format Example
Absolute URL http[s]://www.somewhere.com/some-page?a=b
Root Relative URL /some-page?a=b
Virtual Application Relative URL ~/some-page?a=b

This applies to the Url, CanonicalUrl, and ImageUrl properties/XML attributes.

@jamierytlewski
Copy link
Author

This is what it looks like:

<httpErrors errorMode="Custom" defaultResponseMode="ExecuteURL" existingResponse="Replace">
      <remove statusCode="404" subStatusCode="-1" />
      <remove statusCode="500" subStatusCode="-1" />
      <!-- full url when responsemode is Redirect -->
      <error statusCode="404" path="/error/error404" responseMode="ExecuteURL" />
      <error statusCode="500" path="/error/error500" responseMode="ExecuteURL" />
    </httpErrors>

So it's pretty Root Relative to me.

@NightOwl888
Copy link
Collaborator

No, I was referring to the attributes/properties in your Mvc.sitemap file and/or [MvcSiteMapNode] attributes.

However, if you do not have a <mvcSiteMapNode> defined for your error pages, or you do have them and they are configured correctly, there shouldn't be an error. If that is the case, this may be a bug.

If so, I would appreciate you providing a small demo project with this problem so I can work out what is causing it. You can either post it on GitHub or zip it and make it available for download.

@jamierytlewski
Copy link
Author

Thanks for the quick responses.

https://github.com/jamierytlewski/BrokenMvcSiteMap/

@jamierytlewski
Copy link
Author

Thanks!

@NightOwl888
Copy link
Collaborator

Sure thing. Give it a few minutes for the NuGet package to be built and propagated onto NuGet gallery.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants