使用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...

我做的简单的窗体身份验证的一个小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>
阅读全文

相关推荐

最新文章