记录学习ASP.NET中的点点滴滴.
摘要:这两种方式都是以HttpResponseMessage的形式返回,方式一:以字符串的形式var content = new StringContent("{\"FileName\": \"" + fileName + "\"}");HttpResponseMessage response = new...
阅读全文
摘要:开发Asp.net网站, 开发网站使用Form验证, 需要在Web.config中加入如下节点<authenticationmode="Forms"><formsloginUrl="~/Public/Login"timeout="30"/></authentication>打开带有参数的页面时,如果未登录或登录已超时,会自动跳转到Login页面, 但是当输入完用户名密码后, 如果使用 this.HttpContext.Request.UrlReferrer 获取之前的页面就会发现获取到的Url中包含
阅读全文
摘要:一种是通过JavaScript:<scriptsrc="http://www.cnblogs.com/Scripts/MicrosoftAjax.js"type="text/javascript"></script><scripttype="text/javascript">function deleteRecord(recordId){// Perform deletevar action = "/Home/Delete/" + recordId;var request = n
阅读全文
摘要:A Session State ExamplepublicclassFurniture{publicstringName;publicstringDescription;publicdecimalCost;publicFurniture(stringname,stringdescription,decimalcost){Name=name;Description=description;Cost=cost;}}publicpartialclassSessionStateExample:System.Web.UI.Page{protectedvoidPage_Load(Objectsender,
阅读全文
摘要:Before you can use cookies, you should import the System.Net namespace so you can easily workwith the appropriate types:usingSystem.Net;Cookies are fairly easy to use. Both the Request and Response objects (which are provided throughPage properties) provide a Cookies collection. The important trick
阅读全文
摘要:Transferring Information Between PagesCorss-Page PostingHere’s an example—a page named CrossPage1.aspx that defines a form with two text boxes and a button. When the button is clicked, it posts to a page named CrossPage2.aspx.<%@PageLanguage="C#"AutoEventWireup="true"CodeFile=
阅读全文
摘要:A View State ExamplepublicpartialclassSimpleCounter:System.Web.UI.Page{protectedvoidcmdIncrement_Click(Objectsender,EventArgse){intcounter;if(ViewState["Counter"]==null){counter=1;}else{counter=(int)ViewState["Counter"]+1;}ViewState["Counter"]=counter;lblCount.Text=&quo
阅读全文
摘要:Enabling Tracing<%@PageTrace="true"...%>orprotectedvoidPage_Load(Objectsender,EventArgse){Trace.IsEnabled=true;}By default, trace messages are listed in the order they were written by your code. Alternatively, youcan specify that messages should be sorted by category using the TraceM
阅读全文
摘要:Writing to the Event LogYou can interact with event logs in an ASP.NET page by using the cl asses in the System.Diagnosticsnamespace. First, import the namespace at the beginning of your code-behind file:using System.Diagnostics;The following example rewrites the simple ErrorTest page to use event l
阅读全文