使用主题css文件需要页面上的标题控件.(例如<head runat ="server"/>)

ozk*_*ank 18 asp.net

我正在开发asp.net web项目.当我运行项目时,它正常工作.但在服务器中,我收到以下错误.如何解决这个问题呢?

Using themed css files requires a header control on the page. (e.g. `<head runat="server" />`).
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. How to solve this problem?

Exception Details: System.InvalidOperationException: Using themed css files requires a header control on the page. (e.g. `<head runat="server" />`).

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:
[InvalidOperationException: Using themed css files requires a header control on the page. (e.g. <head runat="server" />).]
   System.Web.UI.PageTheme.SetStyleSheet() +2458406
   System.Web.UI.Page.OnInit(EventArgs e) +8699420
   System.Web.UI.Control.InitRecursive(Control namingContainer) +333
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,  Boolean includeStagesAfterAsyncPoint) +378
Run Code Online (Sandbox Code Playgroud)

Suv*_*iri 47

如果页面不是为了呈现html,我觉得上面的答案都没有解决用户面临的实际问题.在这种情况下,解决方案是 - 只需粘贴以下内容即可

EnableTheming = "False" StylesheetTheme="" Theme="" 
Run Code Online (Sandbox Code Playgroud)

在该页面的@Page属性中.

例如,以下源代码示例:

DownloadFile.aspx.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DownloadFile.aspx.cs"
    Inherits="WebUI.Monitorization.DownloadFile"  EnableTheming="False" StylesheetTheme="" Theme=""   %>
Run Code Online (Sandbox Code Playgroud)

  • 当我试图对一个空的aspx页面进行ajax调用时,这对我有用 (2认同)

Pha*_*bus 12

你需要在页面(或母版页)中使用runat ="server"的头标记,如下所示

<head runat="server">
    <title></title>
</head>
Run Code Online (Sandbox Code Playgroud)


Mic*_*ael 3

对我来说,原因是实时服务器上缺少PrecompiledApp.config文件,因为我在上传之前预编译了站点。