Der Wert fällt nicht in den erwarteten Bereich mit GetServerVariableInternalerC#

Ein Treffpunkt für C#-Programmierer
Anonymous
 Der Wert fällt nicht in den erwarteten Bereich mit GetServerVariableInternaler

Post by Anonymous »

Ich bin mir nicht sicher, warum dieser Fehler auftritt, aber nach dem Quellcode wird er durch GetServerVariableInternal mit dem Wert IIS_WASUrlrewritten verursacht. Warum passiert das und wie kann ich es stoppen? Wenn ich manuell auf diese Seite gehe, passiert es nie. Der Throwiffailedhr wirft immer wieder einen Fehler.

Code: Select all

Error in Path :/177359/2021-2022-abybl-regular-season/schedule
Raw Url :/177359/2021-2022-abybl-regular-season/schedule
Message :Value does not fall within the expected range.
Source :mscorlib
Stack Trace :   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.GenerateClientUrl(HttpContextBase httpContext, String contentPath)
at System.Web.Mvc.UrlHelper.GenerateUrl(String routeName, String actionName, String controllerName, RouteValueDictionary routeValues, RouteCollection routeCollection, RequestContext requestContext, Boolean includeImplicitMvcValues)
at System.Web.Mvc.UrlHelper.GenerateUrl(String routeName, String actionName, String controllerName, String protocol, String hostName, String fragment, RouteValueDictionary routeValues, RouteCollection routeCollection, RequestContext requestContext, Boolean includeImplicitMvcValues)
at System.Web.Mvc.UrlHelper.RouteUrl(String routeName, RouteValueDictionary routeValues, String protocol, String hostName)
at System.Web.Mvc.T4Extensions.Action(UrlHelper urlHelper, ActionResult result)
WashisRequestrewritten

Code: Select all

    private const string UrlWasRewrittenServerVar = "IIS_WasUrlRewritten";
private const string UrlRewriterEnabledServerVar = "IIS_UrlRewriteModule";

private object _lockObject = new object();
private bool _urlRewriterIsTurnedOnValue;
private volatile bool _urlRewriterIsTurnedOnCalculated = false;

private static bool WasThisRequestRewritten(HttpContextBase httpContext)
{
NameValueCollection serverVars = httpContext.Request.ServerVariables;
bool requestWasRewritten = (serverVars != null && serverVars[UrlWasRewrittenServerVar] != null);
return requestWasRewritten;
}

private string GetServerVariableInternal(string name) {
IntPtr buffer;
int bufLen;

int retval = IIS.MgdGetServerVariableW(_context,
name,
out buffer,
out bufLen);

Misc.ThrowIfFailedHr(retval);

if (buffer != IntPtr.Zero) {
return StringUtil.StringFromWCharPtr(buffer, bufLen);
}

return null;
}

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post