在asp.net webservice中如何使用session
在使用asp.net编写webservice时,默认情况下是不支持session的,但我们可以把WebMethod的EnableSession选项设为true来显式的打开它,请看以下例子:
1 新建网站WebSite
2 新建web服务WebService.asmx,它具有以下两个方法:
C#-Code:
[WebMethod(EnableSession = true)]
public string Login(string name)
{
Context.Session["name"] = name;
return name;
}
[WebMethod(EnableSession = true)]
public string GetName()
{
if (Context.Session["name"] != null)
return Context.Session["name"].ToString();
else
return "";
}
3 添加asp.net页面SessionInWebservice.aspx
ASP.NET-Code:
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txtName" runat="server"></asp:TextBox>
<asp:Button ID="btnLogin" runat="server"
Text="Login" OnClick="btnLogin_Click" />
</div>
<div>
<asp:Button ID="btnGetName" runat="server"
Text="GetName" OnClick="btnGetName_Click" />
<asp:Label ID="lblName" runat="server" Text="Label"></asp:Label>
</div>
</form>
SessionInWebservice.aspx.cs
C#-Code:
protected void btnLogin_Click(object sender, EventArgs e)
{
WebService ws = new WebService();
ws.Login(txtName.Text);
}
protected void btnGetName_Click(object sender, EventArgs e)
{
WebService ws = new WebService();
lblName.Text = ws.GetName();
}
问
相关文档:
public class ToEmial
{
string _to;
string _title;
string _content;
string _strHost;
......
3.4理解继承
一.基于原型的继承:
步骤:
(1)在子类构造函数中调用基类构造函数,从而继承基类的属性。
(2)将基类的一个新实例赋给子类,从而继承基类的方法。
Samples.Cat=function()
{
Samples.Pet.call(this);
}
Sample ......
UrlScan的3.1是一个安全的工具,限制了IIS的HTTP请求将处理类型。 通过阻止特定的HTTP请求,在URLScan 3.1安全工具有助于防止对服务器应用程序可能有害的请求。 UrlScan的3.1是URLScan 2.5的更新版本。支持IIS 5.1中,IIS 6.0和IIS 7.0在Windows Vista和Windows Server 2008。下载地址http://download.csdn.net ......
Trustwave's SpiderLabs Security Advisory TWSL2010-001:
Multiplatform View State Tampering Vulnerabilities
Published: 2010-02-08 Version: 1.1
SpiderLabs has documented view state tampering
vulnerabilities in three products from separate vendors.
View states are used by some web application frame ......