授权标签使页面显示为纯文本
我是 Web 技术的新手,我的经验纯粹是 C#。 我从网页设计师那里得到了 HTML 设计,我正在它的基础上进行构建并边学习边学习。
我有一些网页用于授权访问,其他网页用于匿名用户
此外,我了解到拒绝匿名用户的访问是通过在 webconfig 中使用以下更改添加授权标签来完成的
<system.web>
<authentication mode="Forms">
<forms loginUrl="logon.aspx" name=".ASPXFORMSAUTH">
</forms>
</authentication>
<authorization>
<deny users="?" />
</authorization>
</system.web>
但是除了登录页面之外还有其他页面需要允许所有用户访问,例如注册页面
因此我从 msdn 了解到我需要添加一个位置标记来指示这些页面的文件夹 我创建了一个名为“Auth”的文件夹并添加了这些页面 所以我的 web.conf 文件看起来像
<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>
最后,问题是登录后和调试期间,授权访问页面仅显示为纯文本,没有任何格式!?谁能说出为什么会发生这种情况?
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 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为“纯文本”是指您可以正常查看 HTML,但它的样式不是根据设计者(或您的)CSS 文件设计的。
如果您必须将页面移动到 Auth 文件夹中,这可能会破坏该页面所引用的 CSS 文件的链接。
使用以下示例结构
\ - 应用程序的根目录
\ Auth - 包含无法访问的页面
\ 样式 - 包含您的 css 文件(和图像?)
\ Styles \ FileName.css - 您的 css 文件,具有所有漂亮的魔力
\ Logon.aspx - 包含您的登录表单
\ Default.aspx - 包含每个人都可以访问的默认页面
如果不在 Auth 文件夹中的页面显示正常,我的猜测是您的 css 文件将像这样链接:
但是现在您已经移动了页面,该引用不会不指向同一个文件。将其更改为绝对路径,或者在您的情况下,您可以使用 asp.net 应用程序根路径...因此(对于所有页面):
或者
或者如果这些都不起作用,则对于内部页面 你的 auth 文件夹,只需使用上一级语法
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:
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):
Or
Or if none of these are working, for the pages inside your auth folder, just use the up one level syntax