使用ASP.NET窗体身份验证,我怎么得到一个形象出现在登录屏幕上? [英] Using ASP.NET Forms Authentication, how do I get an image to appear on the login screen?

查看:101
本文介绍了使用ASP.NET窗体身份验证,我怎么得到一个形象出现在登录屏幕上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做的简单的窗体身份验证的一个小ASP.NET(3.5,C#)应用程序,并设置了我的用户名和密码在web.config中。

I am doing simple forms authentication for a small ASP.NET (3.5, C#) application and setting up my usernames and passwords in the web.config.

我想申请的默认样式,包括页眉图形(包括所有其他网页上的),但是该图形和样式表将不适用,presumably因为匿名用户没有访问这两个文件。有一些简单的方法,我将它们添加或其他方式使图像显示在页面上?

I would like to apply the default stylesheet and include the header graphic (included on every other page) but the graphic and stylesheet won't apply, presumably because the anonymous user doesn't have access to those two files. Is there some easy way for me to add them or some other way to make the image appear on the page?

下面是web.config中的相应和部分:

Here is the relevent section of the web.config:

<authentication mode="Forms">
  <forms name=".ASPXFORMSAUTH" 
    path="/" 
    loginUrl="login.aspx" 
    protection="All" timeout="30">

    <credentials passwordFormat="SHA1">
      <user
          name="testuser"
          password="hashgoeshere"/>
    </credentials>
  </forms>
</authentication>
<authorization>
  <deny users="?" />
</authorization>

样式表是: /stylesheet.css 并且图像是在: /img/logoimage.png

The stylesheet is at: /stylesheet.css and the image is at: /img/logoimage.png

感谢。这个网站让我很高兴,因为希望它将使专家交流和他们跛脚收费墙死!

Thanks. This site makes me happy because hopefully it will make Experts Exchange and their lame paywall DIE!

推荐答案

您可以在你的web.config使用特定位置的规则(system.web节之后添加这些)添加例外:

You can add exceptions in your Web.Config using location-specific rules (add these after the System.Web section):

<location path="stylesheet.css">
    <system.web>
    	<authorization>
    		<allow users="*" />
    	</authorization>
    </system.web>
</location>

<location path="img/">
    <system.web>
    	<authorization>
    		<allow users="*" />
    	</authorization>
    </system.web>
</location>

这篇关于使用ASP.NET窗体身份验证,我怎么得到一个形象出现在登录屏幕上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆