aspnet / AspNetWebStack

ASP.NET MVC 5.x, Web API 2.x, and Web Pages 3.x (not ASP.NET Core)
Other
858 stars 354 forks source link

Cannot use a leading .. to exit above the top directory. #217

Closed xunter closed 5 years ago

xunter commented 5 years ago

https://github.com/aspnet/AspNetWebStack/blob/39d3064baf13181f5718ec5d85ba644b47d0704b/src/System.Web.WebPages/Utils/UrlUtil.cs#L108

Issue in ASP.NET MVC app during urls generation with UrlHelper.GenerateContentUrl/Url.Content when UrlRewrite is configured to rewrite links not redirect. when I use UrlRewrite with url rewrite from public /seo-friendly-name-url to server /Home/Index/123, for instance, I get this error due the logic in code lines: 106, 107, 108

There is workaround I posted at stackoverflow: https://stackoverflow.com/a/53852932/1487713

My full stack trace:

System.Web.HttpException (0x80004005): Cannot use a leading .. to exit above the top directory. at System.Web.Util.UrlPath.ReduceVirtualPath(String path) at System.Web.Util.UrlPath.Reduce(String path) at System.Web.VirtualPath.Combine(VirtualPath relativePath) at System.Web.VirtualPathUtility.Combine(String basePath, String relativePath) at System.Web.WebPages.UrlUtil.GenerateClientUrlInternal(HttpContextBase httpContext, String contentPath) at System.Web.WebPages.UrlUtil.GenerateClientUrlInternal(HttpContextBase httpContext, String contentPath) at System.Web.WebPages.UrlUtil.GenerateClientUrl(HttpContextBase httpContext, String basePath, String path, Object[] pathParts)

dougbu commented 5 years ago

Thank you for your feedback. We're closing this issue as the behaviour discussed is by design.