母版页继承标签问题

时间:2010-03-17 20:05:10

标签: asp.net master-pages

通过列出的here列出的Microsoft身份验证教程,您可以创建母版页。在Visual Studio生成后,文件中的第一个列表如下所示:

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="FormsAuthentication.Site" %>

该项目称为FormAuthentication,主页面名为Site.Master。运行项目时,我收到错误:

Compiler Error Message: CS0426: The type name 'Site' does not exist in the type 'System.Web.Security.FormsAuthentication'

,引用的行在自动生成的文件

中如下所示
Line 133:        [TemplateContainer(typeof(FormsAuthentication.Site))]

删除该初始标记的“Inherits ='FormsAuthentication.Site'”部分可以解决问题,但我正在尝试了解这里发生了什么。这里到底发生了什么?

2 个答案:

答案 0 :(得分:5)

项目名称(可能是名称空间)与ASP.NET表单身份验证类名称System.Web.Security.FormsAuthentication冲突。我认为你缺少命名空间名称或参考。

答案 1 :(得分:1)

如果您可以重命名,或者在FormsAU身份验证周围添加另一级别的命名空间,那么它就像:Custom.FormsAuthentication.Site,这样可以缓解这个问题。