The problem is:
- I have installed
UrlRewrite
modole on my IIS for "A" website I have "B" web site (MVC 5.0) which doesn't use 'UrlRewrite' module but get exception when calling
UrlHelper.Content("~/blobl/foo/bar")
. The exception is because of usingUrlRewriter
module and using~
character for function parameter at same time. The exception is:System.ArgumentException: Value does not fall within the expected range. at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo) at System.Web.Hosting.IIS7WorkerRequest.GetServerVariableInternal(String name) at System.Web.WebPages.UrlRewriterHelper.WasThisRequestRewritten(HttpContextBase httpContext) 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 contentPath)
If I uninstall UrlRewrite
module, everything will be OK but the "A" website encounters problem. Also, I couldn't find any way to disable this module only for a website.
NOTE: I've checked IIS URL Rewrite module: Url.Content() does not resolve CSS/Image path properly but I don't want to change the source code.