从重定向到l​​ogin.aspx的prevent ASP.NET [英] Prevent ASP.NET from redirecting to login.aspx

查看:208
本文介绍了从重定向到l​​ogin.aspx的prevent ASP.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有完全运行在AngularJS有一个ASP.NET Web API后端,配置如下网站: - HTML5路由角上启用并有在web.config中重写规则将所有流量的index.html - MVC未安装(仅剃须刀页) - 验证操作使用窗体身份验证及相关的Cookie

我刚添加的赫利IIS插件具有的.htaccess密码保护我们的开发服务器(这是一个烂摊子与IIS独自做到这一点),但我有一个基本的问题。

在我输入的基本身份验证凭据,我会重定向到 /login.aspx?ReturnUrl = ,虽然我不知道谁是负责这个( IIS或Helicon的插件),它将匹配我的AngularJS途径之一,并导致错误。

我怎样才能阻止这种情况的发生重定向?

我的web.config中验证一下:

 <身份验证模式=形式>
  <形成保护=所有超时=15NAME =路径=/requireSSL =假slidingExpiration =假无Cookie =UseCookiesenableCrossAp predirects =FALSE/&GTASPXAUTH。 ;
< /认证>
 

解决方案

如果你正在使用ASP.NET 4.5。 您可以禁用窗体身份验证重定向 HTT presponse.Sup pressFormsAuthenticationRedirect属性。

在Global.asax中:

 保护无效Application_EndRequest(对象发件人,EventArgs的)
{
        HttpApplication的情况下=(HttpApplication的)发送;
        context.Response.Sup pressFormsAuthenticationRedirect = TRUE;
}
 

We have a website that runs fully on AngularJS with an ASP.NET Web API back-end with the following configuration: - HTML5 routing is enabled on Angular and there is a rewrite rule in web.config to direct all traffic to index.html - MVC is not installed (only razor pages) - Authentication happens using Forms Authentication and related cookies

I have just added the Helicon IIS plugin to have .htaccess password protected for our development server (it's a mess to do it with IIS alone) but I have a basic problem.

After I input the basic auth credentials, I will get a redirect to /login.aspx?ReturnUrl= and although I'm not sure who is responsible for this (IIS or Helicon plugin), it will match one of my AngularJS routes and result in an error.

How can I stop this redirect from happening?

My web.config authentication bit:

<authentication mode="Forms">
  <forms protection="All" timeout="15" name=".ASPXAUTH" path="/" requireSSL="false" slidingExpiration="false" cookieless="UseCookies" enableCrossAppRedirects="false" />
</authentication>

解决方案

If you are using ASP.NET 4.5. you can disable forms authentication redirect HttpResponse.SuppressFormsAuthenticationRedirect property.

In Global.asax:

protected void Application_EndRequest(Object sender, EventArgs e)
{
        HttpApplication context = (HttpApplication)sender;
        context.Response.SuppressFormsAuthenticationRedirect = true;
}

这篇关于从重定向到l​​ogin.aspx的prevent ASP.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆