- 爱易网页
-
ASP.NET教程
- web.config无法限定htm文件,只能限定aspx,该怎么解决
日期:2014-05-19 浏览次数:20524 次
web.config无法限定htm文件,只能限定aspx
web.config无法限定htm文件,只能限定aspx.
当访问到服务器的htm文件时,它却直接打开了,根本就没转向指定的登陆界面!访问其他的aspx文件却能正常转向.应该怎么处理?
web.config
<?xml version= "1.0 " encoding= "utf-8 "?>
<configuration>
<system.web>
<authentication mode= "Forms " >
<forms name= ".iis-root " loginUrl= "Default.aspx "/>
</authentication>
<authorization>
<deny users= "? "/>
</authorization>
</system.web>
</configuration>
----------------------------------------------
Default.aspx
<html>
<head>
<title> 无标题页 </title>
</head>
<body>
<form id= "form1 " method= "post " runat= "server ">
<asp:TextBox ID= "TextBox1 " runat= "server "/>
<br> <asp:Button ID= "Button1 " runat= "server " Text= "提交 " OnClick= "Button1_Click "/>
<br> <asp:Label ID= "Label1 " runat= "server " Text= "asdasd " />
</form>
</body>
</html>
<script language= "C# " runat= "server ">
void Button1_Click(object sender, System.EventArgs e)
{
if(TextBox1.Text== "110 ")
{
System.Web.Security.FormsAuthentication.SetAuthCookie(TextBox1.Text, false);
Response.Redirect( "data2.aspx ");
}
else
{
Label1.Text= "用户名错误,请重新输入 ";
}
}
</script>
------解决方案--------------------
简单的可以用一个隐藏框架指向一个checkLogin.aspx
不知道在iis里把htm的ISAPI指向aspnet_isapi.dll能不能有用
以上方法都没有试过,楼主可以试试