ASP.NET theme not rendering correctly

前端 未结 5 1041
小蘑菇
小蘑菇 2021-01-28 06:12

I have a small web application which uses themes. The themes work on host, so on preinit, if the host = a, load x theme, if the host = b, load y theme.

In my code this

相关标签:
5条回答
  • 2021-01-28 06:37

    Are you setting the Theme early enough in your code? A Theme must be applied to a page very early in the request lifecycle, in the PreInit event, if you do it in code-behind.

    0 讨论(0)
  • 2021-01-28 06:44

    I have enabled and installed all the sub features in

    Internet Information Services --> World Wide Web Services --> Common HTTP Features

    This solved by Theme not working problem.

    0 讨论(0)
  • 2021-01-28 06:52

    Yep, it is on page preinit.

    I think it is to do with forms authentication. If I view (not debug) the login page, it picks up the localhost theme and everything is displayed correctly. The login control is in the middle of the page, as it should be, etc.

    But if I debug the page and, as you'd expect, the login page is the start/default page, the login control appears to the left as it does when I deploy and the source indicates the css for the appropriate host has been picked up - only when I debug, there is no style applied until I login.

    0 讨论(0)
  • 2021-01-28 06:52

    Are you using the built-in web server? When running in ASP.Net Development Server, the styles in App_Themes won't be used on any unauthenticated page (such as Login.aspx or ForgotPassword.aspx). That's because the user doesn't have browse permissions on that folder yet, or the App_Themes folder lacks browsing permissions. Apparently, IIS handles this but Cassini doesn't.

    Try adding this to web.config to let Themes and styles work before authentication.

    Or, if possible, switch to running the app on IIS on your machine.

    0 讨论(0)
  • 2021-01-28 06:53

    I encountered this problem recently and wrote a quick blog that explains how to get around it. Just in case someone else is having this problem, you just need to authorize the Theme folder in your web.config.

    0 讨论(0)
提交回复
热议问题