ASP.NET表单身份验证-登录页面上的JavaScript错误(当匿名用户访问时) [英] ASP.NET Forms Authentication - JavaScript errors on Login page (when anonymous users visit)

查看:109
本文介绍了ASP.NET表单身份验证-登录页面上的JavaScript错误(当匿名用户访问时)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

仅在我的登录页面上,我遇到18个JavaScript错误,主要的错误似乎是:"ASP.NET Ajax客户端框架加载失败."我有一种感觉,它与安全性有关,因为我最近才向该站点添加了表单身份验证.如果我登录,所有错误都会消失.

On my Login page only I am getting 18 JavaScript errors and the main one seems to be: 'ASP.NET Ajax client-side framework failed to load.' I have a feeling it has to do with security since I just recently added Forms Authentication to the site. If I login all errors go away.

当此行尝试运行时,似乎sys是未定义的:

It seems like sys is undefined when this line tries to run :

if (typeof(Sys) === 'undefined') throw new Error('ASP.NET Ajax client-side framework failed to load.');

我的Web.config中包含以下内容:

I have the following in my Web.config:

<authentication mode="Forms">
  <forms name=".FormsAuthCookie" loginUrl="Security/Login" protection="All" timeout="120" cookieless="AutoDetect" />
</authentication>
<authorization>
  <deny users="?"/>
</authorization>

添加拒绝用户=?之后的主要问题:" 当匿名用户访问该站点时,ASP.NET Ajax客户端框架无法在我的Login.aspx页面上加载.

THE MAIN PROBLEM after adding deny users="?": ASP.NET Ajax client-side framework is failing to load on my Login.aspx page when an anonymous user visits the site.

更新:::
这确实没有多大意义,但是在将EnableCdn ="true"添加到我的脚本管理器之后,当匿名用户访问登录页面时,我没有收到任何错误....问题是因为这是一个干净的.net Webforms项目.

UPDATE:::
This really doesn't make much sense but after adding EnableCdn="true" to my script manager I do not get any errors when an anonymous user visits the login page.... It just seems like it is a hack for whatever my actual problem is since this is a clean .net webforms project.

<asp:ScriptManager runat="server" EnableCdn="True">

推荐答案

诸如身份验证之类的声音阻止了对javascript库的访问.如果您在Chrome浏览器中查看网络"标签,加载js文件时会遇到任何错误吗?如果是这样,我会说在您的配置文件中的目录中添加一个例外.

Sounds like the authentication is blocking access to the javascript library. if you view the network tab in chrome do you get any errors loading the js files? if so I would say add an exception to the directory in your config file.

类似的东西:

<location path="js">
    <system.web>
      <authorization>
        <allow users="*"/>
      </authorization>
    </system.web>
  </location>

我认为CDN起作用的原因是因为文件正从CDN加载到您的应用程序,因此CDN服务器不需要身份验证.

I think the reason CDN works is because the files are being loaded from a CDN as oppose to your app so there is no authentication needed for the CDN server.

这篇关于ASP.NET表单身份验证-登录页面上的JavaScript错误(当匿名用户访问时)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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