我試圖在asp.net MVC 1.0中實現一個customRoleProvider。這個類看起來像這樣roleManager在Default.aspx.cs中導致invalidOperationException
using System;
using System.Web.Security;
namespace Project.Web.Services
{
public class CustomRoleProvider: RoleProvider
{
public override bool IsUserInRole(string username, string roleName)
{
throw new NotImplementedException();
}
public override string[] GetRolesForUser(string username)
{
throw new NotImplementedException();
}
public override void CreateRole(string roleName)
{
throw new NotImplementedException();...
我已經設置了Web.config文件如下
<configuration>
<system.web>
<roleManager enabled="true" defaultProvider="CustomRoleProvider">
<providers>
<clear/>
<add name="CustomRoleProvider" type="Project.Web.Services.CustomRoleProvider" />
</providers>
</roleManager>
...
當我這樣做,我得到Default.aspx中拋出一個InvalidOperationException異常。來自碼的httpHandler.ProcessRequest(HttpContext.Current);
線以下
public partial class _Default : Page
{
public void Page_Load(object sender, System.EventArgs e)
{
// Change the current path so that the Routing handler can correctly interpret
// the request, then restore the original path so that the OutputCache module
// can correctly process the response (if caching is enabled).
string originalPath = Request.Path;
HttpContext.Current.RewritePath(Request.ApplicationPath, false);
IHttpHandler httpHandler = new MvcHttpHandler();
httpHandler.ProcessRequest(HttpContext.Current);
HttpContext.Current.RewritePath(originalPath, false);
}
}
中描述了錯誤的CS如下所示 無法找到'索引'或其主人的視圖。以下地點搜索: 〜/瀏覽/首頁/的Index.aspx 〜/瀏覽/首頁/ Index.ascx 〜/查看/共享/的Index.aspx 〜/查看/共享/ Index.ascx
當我從Web.config文件中刪除roleManager問題消失,問題甚至reapears當我把以下行的Web.config
<roleManager enabled="false"></roleManager>
是否有其他財產以後我需要做什麼?
嗨, 我試着重命名默認爲backupdefault,但是項目在啓動項目時仍然運行backupdefault頁面/類。有沒有其他人沒有這個問題? – Evan 2010-01-12 22:28:56