查看: 888|回复: 18
|
asp.net web.config的问题。
[复制链接]
|
|
我从一些地方看来的。
- 以下示例为基于窗体(Forms)的身份验证配置站点,当没有登陆的用户访问需要身份验证的网页,网页自动跳转到登陆网页。
- <authentication mode="Forms" >
- <forms loginUrl="logon.aspx" name=".FormsAuthCookie"/>
- </authentication>
复制代码
请问,是不是这样写会变成每一个网页都要login先。
还是要加其他的code它才会这样。
谢谢各位大大 |
|
|
|
|
|
|
|
发表于 23-2-2006 10:26 AM
|
显示全部楼层
|
|
|
|
|
|
|

楼主 |
发表于 23-2-2006 10:34 AM
|
显示全部楼层
有example最好。
还有谢谢的回复。 |
|
|
|
|
|
|
|

楼主 |
发表于 23-2-2006 01:30 PM
|
显示全部楼层
- <forms name="appNameAuth" path="/" loginUrl="login.aspx" protection="All" timeout="30">
- <credentials passwordFormat="Clear">
- <user name="jeff" password="test" />
- <user name="mike" password="test" />
- </credentials>
- </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.
- <configuration>
- <system.web>
- <customErrors mode="Off"/>
- <authentication mode="Forms"> <- ERROR
- <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 |
|
|
|
|
|
|
|

楼主 |
发表于 24-2-2006 04:38 PM
|
显示全部楼层
谢谢 石破天金 的回复。
还有我那个error是怎么回事呢????? |
|
|
|
|
|
|
|

楼主 |
发表于 25-2-2006 10:12 AM
|
显示全部楼层
|
|
|
|
|
|
|
发表于 26-2-2006 02:40 AM
|
显示全部楼层
Login / Authentication in Web.config
- <authentication mode="Forms">
- <forms name="YourProjectName" loginUrl="login.aspx" />
- </authentication>
- <authorization>
- <deny users="?" /> <!-- deny cookiless users -->
- <allow users="*" /> <!-- Allow all users -->
- </authorization>
- <!-- Below allows specific page to skip authentication -->
- <location path="page_to_be_skipped1.aspx">
- <system.web>
- <authorization>
- <allow users="*" />
- </authorization>
- </system.web>
- </location>
- <location path="page_to_be_skipped2.aspx">
- <system.web>
- <authorization>
- <allow users="*" />
- </authorization>
- </system.web>
- </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
|
显示全部楼层
|
|
|
|
|
|
|

楼主 |
发表于 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呢?? |
|
|
|
|
|
|
|

楼主 |
发表于 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
|
显示全部楼层
|
|
|
|
|
|
| |
本周最热论坛帖子
|