Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/328.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# ';答复';不包含';重定向';_C#_.net_Saml_System.web - Fatal编程技术网

C# ';答复';不包含';重定向';

C# ';答复';不包含';重定向';,c#,.net,saml,system.web,C#,.net,Saml,System.web,我正在尝试使用AspNetSaml nuget包(),在尝试使用Response.Redirect(url)方法时出错 这就是错误: 错误CS0117“响应”不包含“重定向”的定义 我已经在使用名称空间System.Web,而且我还添加了System.Web.dll static void Redir(Response samlResponse) { //specify the SAML provider url here, aka "Endpoint" var samlEndp

我正在尝试使用AspNetSaml nuget包(),在尝试使用
Response.Redirect(url)
方法时出错

这就是错误:

错误CS0117“响应”不包含“重定向”的定义

我已经在使用名称空间
System.Web
,而且我还添加了
System.Web.dll

static void Redir(Response samlResponse)
{
    //specify the SAML provider url here, aka "Endpoint"
    var samlEndpoint = "https://saml.xxxx.com/idp/SSO.saml2";

    AuthRequest request = new AuthRequest(
        "https://www.xxxx.com/", //put your app's "unique ID" here
        "https://www.xxxx.com/" //assertion Consumer Url - the redirect URL where the provider will send authenticated users
        );

    // Generate the provider URL
    string url = request.GetRedirectUrl(samlEndpoint);

    Response.Redirect(url);
}

看起来您正试图从静态方法访问页面的
HttpResponse
对象。使您的方法非静态:

void Redir(Response samlResponse)
{
    ...
    this.Response.Redirect(url);
}

看起来您正试图从静态方法访问页面的
HttpResponse
对象。使您的方法非静态:

void Redir(Response samlResponse)
{
    ...
    this.Response.Redirect(url);
}

您可以只替换函数调用

Redire(this.Response)


使用Redire函数返回要重定向到的url。通过这种方式,您将摆脱造成问题的静态上下文。

您只需替换函数调用即可

Redire(this.Response)

使用Redire函数返回要重定向到的url。这样,您就可以摆脱造成问题的静态上下文