C#一般处理程序

以.ashx为后缀

context.Response.ContentType = "text/html";
返回前端html页面(sb为html页面)context.Response.Write(sb);

//判断是否是第一次请求
       if (context.Request.HttpMethod.ToLower().Equals("get"))
       {
           
       }
--前端以form 表单,input、select、textare为主向后端提交数据,必须含有name属性
 1  <form action="Edit.ashx" method="post">
 2         <table>
 3             <tr>
 4                 <td>StorID:</td>
 5                 <td><input type="text" name="txtStorId" value="@vStorId" readonly="readonly" /></td>
 6             </tr>
 7             <tr>
 8                 <td>MSPTypeName:</td><td><input type="text" name="txtTypeNm" value="@vTypeNm"/></td>
 9             </tr>
10             <tr>
11                 <td>StoreName:</td>
12                 <td><input type="text" name="txtStorNm" value="@vStor_nm" /></td>
13             </tr>
14             <tr>
15                 <td colspan="2"><input type="submit" value="修改"/></td>
16             </tr>
17         </table> 
18     </form>
string result = File.ReadAllText(context.Request.MapPath("/SelfIncrease.html"));
通过context.Request.MapPath("/SelfIncrease.html")获取前端页面的物理地址,(File.ReadAllText只能读取物理地址)




原文地址:https://www.cnblogs.com/allenzhang/p/6625759.html