佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 886|回复: 18

asp.net web.config的问题。

[复制链接]
发表于 23-2-2006 09:47 AM | 显示全部楼层 |阅读模式
我从一些地方看来的。


  1. 以下示例为基于窗体(Forms)的身份验证配置站点,当没有登陆的用户访问需要身份验证的网页,网页自动跳转到登陆网页。

  2. <authentication mode="Forms" >
  3. <forms loginUrl="logon.aspx" name=".FormsAuthCookie"/>

  4. </authentication>
复制代码


请问,是不是这样写会变成每一个网页都要login先。

还是要加其他的code它才会这样。

谢谢各位大大
回复

使用道具 举报


ADVERTISEMENT

发表于 23-2-2006 10:26 AM | 显示全部楼层
你可参考以下网页
http://www.15seconds.com/issue/020220.htm
有example
回复

使用道具 举报

 楼主| 发表于 23-2-2006 10:34 AM | 显示全部楼层
原帖由 cky_2003 于 23-2-2006 10:26 AM 发表
你可参考以下网页
http://www.15seconds.com/issue/020220.htm
有example



有example最好。

还有谢谢的回复。
回复

使用道具 举报

 楼主| 发表于 23-2-2006 01:30 PM | 显示全部楼层

  1. <forms name="appNameAuth" path="/" loginUrl="login.aspx" protection="All" timeout="30">
  2.    <credentials passwordFormat="Clear">
  3.         <user name="jeff" password="test" />
  4.         <user name="mike" password="test" />
  5.     </credentials>
  6. </forms>
复制代码


如果我的name是从db哪里来的呢?
又要如何写?

[ 本帖最后由 红发 于 23-2-2006 01:32 PM 编辑 ]
回复

使用道具 举报

 楼主| 发表于 24-2-2006 10:31 AM | 显示全部楼层
还有我遇到一个error。

Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level.  This error can be caused by a virtual directory not being configured as an application in IIS.



  1. <configuration>
  2.     <system.web>
  3.         <customErrors mode="Off"/>
  4.         <authentication mode="Forms">  <- ERROR
  5.             <forms name="appNameAuth" path="/" loginUrl="login.aspx" protection="All" timeout="30">

复制代码
回复

使用道具 举报

发表于 24-2-2006 02:56 PM | 显示全部楼层
<authentication mode="Forms">
                <forms name="appNameAuth" path="/" loginUrl="Index.aspx" protection="All" timeout="30">
                </forms>
        </authentication>

</system.web>
<!-- user authentications path -->
    <location path="A_AgentContactDetails.aspx">
        <system.web>
            <authorization>
                <deny users="?"/>
            </authorization>
        </system.web>
    </location>
    <location path="GP_GolfPackBookings.aspx">
        <system.web>
            <authorization>
                <deny users="?"/>
            </authorization>
        </system.web>
    </location>   

你可以加任何的form to control by using this setting。当user access these form without login, page will auto redirect to Index.aspx to login。

当userlogin后,就加入这些codes。当user 再 access 这些pages 时,就不需要再login了

If Request.QueryString("ReturnURL") <> "" Then
                        FormsAuthentication.RedirectFromLoginPage(STxtUserName.Text, False)
                    Else
                        FormsAuthentication.SetAuthCookie(STxtUserName.Text, False) 'not set cookie  
                        Response.Redirect("Home.aspx", False)
                    End If
回复

使用道具 举报

Follow Us
 楼主| 发表于 24-2-2006 04:38 PM | 显示全部楼层
谢谢 石破天金 的回复。

还有我那个error是怎么回事呢?????
回复

使用道具 举报

 楼主| 发表于 25-2-2006 10:12 AM | 显示全部楼层
知道error的问题了。。。。。
回复

使用道具 举报


ADVERTISEMENT

seagull 该用户已被删除
发表于 26-2-2006 02:40 AM | 显示全部楼层
Login / Authentication in Web.config


  1. <authentication mode="Forms">
  2.     <forms name="YourProjectName" loginUrl="login.aspx" />
  3. </authentication>

  4. <authorization>
  5.     <deny users="?" />  <!-- deny cookiless users -->
  6.     <allow users="*" /> <!-- Allow all users -->
  7. </authorization>

  8. <!-- Below allows specific page to skip authentication -->

  9. <location path="page_to_be_skipped1.aspx">
  10.     <system.web>
  11.         <authorization>
  12.             <allow users="*" />
  13.         </authorization>
  14.     </system.web>
  15. </location>

  16. <location path="page_to_be_skipped2.aspx">
  17.     <system.web>
  18.         <authorization>
  19.             <allow users="*" />
  20.         </authorization>
  21.     </system.web>
  22. </location>
复制代码
回复

使用道具 举报

发表于 26-2-2006 08:57 PM | 显示全部楼层
原帖由 红发 于 25-2-2006 10:12 AM 发表
知道error的问题了。。。。。


什么问题呢??我没有看过这个error message
回复

使用道具 举报

 楼主| 发表于 27-2-2006 09:10 AM | 显示全部楼层
原帖由 石破天金 于 26-2-2006 08:57 PM 发表


什么问题呢??我没有看过这个error message



问题是这样的。

如果我这样跑 localhost/login.aspx 是没有问题的。

如果我这样的话 localhost/test/login.aspx 就会有error.

原因就是 test 的 folder 的问题。

那就要去到IIS那里set test 的folder 一样咚咚。(忘了叫什么)

让后按create就可以了
回复

使用道具 举报

 楼主| 发表于 6-3-2006 04:30 PM | 显示全部楼层
原帖由 石破天金 于 24-2-2006 02:56 PM 发表
If Request.QueryString("ReturnURL") <> "" Then
                        FormsAuthentication.RedirectFromLoginPage(STxtUserName.Text, False)
                    Else
                        FormsAuthentication.SetAuthCookie(STxtUserName.Text, False) 'not set cookie  
                        Response.Redirect("Home.aspx", False)
                    End If


想问问这个是不是也是放在web.config里呢?

[ 本帖最后由 红发 于 6-3-2006 04:32 PM 编辑 ]
回复

使用道具 举报

发表于 6-3-2006 04:55 PM | 显示全部楼层
不是, 放在 vb code 里
回复

使用道具 举报

 楼主| 发表于 7-3-2006 09:15 AM | 显示全部楼层
是不是好像这样的

index.aspx <- main pager

index.aspx.vb <- 是不是放在这里的
回复

使用道具 举报

走向流沙 该用户已被删除
发表于 8-3-2006 04:55 AM | 显示全部楼层
原帖由 红发 于 27-2-2006 09:10 AM 发表



问题是这样的。

如果我这样跑 localhost/login.aspx 是没有问题的。

如果我这样的话 localhost/test/login.aspx 就会有error.

原因就是 test 的 folder 的问题。

那就要去到IIS那里set  ...



这叫Application folder, Create Default application pool.

IIS > Websites > Browse到文件夹 > 右键 > Properties > Create > Allow Script only
回复

使用道具 举报

 楼主| 发表于 10-3-2006 01:04 PM | 显示全部楼层
谢谢走向流沙的回答。

还有一个问题。

就是有什么方法可以让人家online开不到我的web.config的file呢??
回复

使用道具 举报


ADVERTISEMENT

 楼主| 发表于 10-3-2006 05:18 PM | 显示全部楼层
没有这个方法吗???
回复

使用道具 举报

发表于 11-3-2006 04:36 PM | 显示全部楼层
原帖由 红发 于 10-3-2006 01:04 PM 发表
谢谢走向流沙的回答。

还有一个问题。

就是有什么方法可以让人家online开不到我的web.config的file呢??


别人开得到你的web.config吗?如何开呢?
应该是开不到的,除非在server里面开
回复

使用道具 举报

 楼主| 发表于 13-3-2006 09:20 AM | 显示全部楼层
IE不就是开的到吗???
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 15-8-2025 06:38 PM , Processed in 0.737478 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表