开发者

Authorization tag makes the page appear as plain text

开发者 https://www.devze.com 2023-02-18 21:40 出处:网络
I am newbie to web technology, and my experience is 开发者_如何转开发purely C#. I got an HTML design from a web designer, and I am building over it and learning as I go.

I am newbie to web technology, and my experience is 开发者_如何转开发purely C#. I got an HTML design from a web designer, and I am building over it and learning as I go.

I have some web pages for authorized access and others for anonymous users

Also, I learned that denying access for anonymous users is done through adding the authorization tag using the following change in the webconfig

<system.web>
  <authentication mode="Forms">
    <forms loginUrl="logon.aspx" name=".ASPXFORMSAUTH">
    </forms>
  </authentication>
  <authorization>
    <deny users="?" />
  </authorization>
</system.web>

However there're other pages than the login page that need to allow access for all users like registeration pages

So I learned from msdn that I needed to add a location tag that indicates the folder for these pages I created a folder called "Auth" and added these pages so my web.confile looks something like

<location path="Auth">
        <system.web>
            <authorization>
                <deny users="?" />
            </authorization>
        </system.web>
    </location>

    <system.web>
        <authentication mode="Forms">
            <forms loginUrl="logon.aspx" name=".ASPXFORMSAUTH">
            </forms>
        </authentication>
    </system.web>

Finally, the problem is that after login and during debugging, the Authorized access pages are appearing as plain text only without any formatting !? can anyone tell why this is happening ?


I presume by "plain text" you mean that you can view your HTML ok, but it isn't styled according to the designers (or your) CSS file.

If you had to move the pages into the Auth folder, this may have broken the link to the CSS file that the page had a reference to.

Using the following sample structure

\ - Root of App
\ Auth - Contains the pages anon cannot access
\ Styles - Contains your css files (and images?)
\ Styles \ FileName.css - your css file with all the pretty magic
\ Logon.aspx - Contains your logon form
\ Default.aspx - Contains your default page that everyone can access

If the pages not in the Auth folder display fine, my guess is that your css file would have been linked like this:

<link rel="Stylesheet" type="text/css" href="Styles/FileName.css">

But now that you have moved the pages, that reference doesn't point at the same file. Change it to be an absolute path, or in your case you can use the asp.net app root path....so this (for all pages):

<link rel="Stylesheet" type="text/css" href="~/Styles/FileName.css">

Or

<link rel="Stylesheet" type="text/css" href="/Styles/FileName.css">

Or if none of these are working, for the pages inside your auth folder, just use the up one level syntax

<link rel="Stylesheet" type="text/css" href="../Styles/FileName.css">
0

精彩评论

暂无评论...
验证码 换一张
取 消