简体   繁体   English

ASP.NET角色在已部署的ASP.NET MVC应用程序中不起作用

[英]ASP.NET Roles not working in deployed ASP.NET MVC application

I have published and deployed an ASP.NET MVC application that uses the Roles feature of ASP.NET authentication. 我已经发布并部署了一个使用ASP.NET身份验证的“角色”功能的ASP.NET MVC应用程序。 On my development machine, Roles work fine - but on my server , to which I've transferred the build, the entire database (schema, data, and users), and with full permissions, Roles don't work . 在我的开发机器上,角色可以正常工作-但将构建,整个数据库(架构,数据和用户)转移到的服务器上 ,并且在具有完全权限的情况下, 角色不起作用

Here is the line where my code crashes: 这是我的代码崩溃的行:

var exists = Roles.RoleExists("Administrator");

For some reason, such Roles queries aren't working, but System.Web.Security.Roles.Enabled returns true and System.Web.Security.Roles.Provider is set properly. 由于某种原因,此类Roles查询无法正常工作,但是System.Web.Security.Roles.Enabled返回true并且System.Web.Security.Roles.Provider设置正确。

What gives? 是什么赋予了?

If I had to take a guess, authentication is set up incorrectly on IIS on the server you have deployed to. 如果我不得不猜测,身份验证在部署到的服务器上的IIS上设置不正确。 Most likely, you used the built in developer server to develop and you have now deployed to a server that has default settings in IIS. 最有可能的是,您使用内置的开发人员服务器进行开发,现在已部署到IIS中具有默认设置的服务器。

I found the solution, and it turned out to be unrelated to ASP.NET. 我找到了解决方案,结果证明它与ASP.NET无关。 The problem, which I found in my SQL logs, was that my SQL user did not have the EXECUTE permission for the database . 我在SQL日志中发现的问题是我的SQL用户没有对该数据库的EXECUTE权限 All it took was a simple query: 它所要做的只是一个简单的查询:

CREATE ROLE db_executor;
GRANT EXECUTE TO db_executor;

Thanks to everyone for their help. 感谢大家的帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM