小弟刚学asp 遇到一些脑残级的问题,求大神

skyming 2013-04-18 07:07:45
问题:小弟新建的一个空的asp 网站,然后又只建了 html 和ashx 两个界面,为什么登录后
html 代码不解析了如下是登录后的界面 :

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>登陆程序</title>
</head>
<body>
<form action="SimgleLogin.ashx" method="post" >

<input type ="text" name="txtName" />
<input type ="text" name="txtPwd" />
<input type ="submit" value="登陆" />
</form>


</body>
</html>
我登陆成功了----

源码是:
ashx 里的代码:
<%@ WebHandler Language="C#" Class="Handler" %>

using System;
using System.Web;

public class Handler : IHttpHandler {

public void ProcessRequest (HttpContext context) {

string modePath = context.Server.MapPath("HTMLPage.htm");

string htmlSendBack= System.IO.File.ReadAllText(modePath);

context.Response.ContentType = "text/plain";
context.Response.Write(htmlSendBack);

if (!string.IsNullOrEmpty(context.Request.Form["txtName"]))
{
if(context.Request.Form["txtName"]=="skyming"&&context.Request.Form["txtPwd"]=="111")
context.Response.Write("我登陆成功了----");
}
else
{
context.Response.Write("我登陆失败了----");
}
}

public bool IsReusable {
get {
return false;
}
}

}
html 里面的代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>登陆程序</title>
</head>
<body>
<form action="SimgleLogin.ashx" method="post" >

<input type ="text" name="txtName" />
<input type ="text" name="txtPwd" />
<input type ="submit" value="登陆" />
</form>


</body>
</html>
...全文
226 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
wxl1010 2013-04-19
  • 打赏
  • 举报
回复
context.Response.ContentType = "text/plain";改成context.Response.ContentType = "text/html"试试呢
skyming 2013-04-19
  • 打赏
  • 举报
回复
引用 1 楼 wxl1010 的回复:
context.Response.ContentType = "text/plain";改成context.Response.ContentType = "text/html"试试呢
改了,3Q

12,162

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 Web Services
社区管理员
  • Web Services社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧