ajax 安全性
完全适用ASP.NET的认证机制
–可以使用FormsAuthentication
•WebService方法可以操作Cookie
–Impersonation
–PrincipalPermission
WebService7.cs Code
using System;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.Script.Services;
/// <summary>
/// WebService7 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService]
public class WebService7 : System.Web.Services.WebService {
public WebService7 () {
//如果使用设计的组件,请取消注释以下行
//InitializeComponent();
}
[WebMethod]
public string HelloWorld() {
if (!HttpContext.Current.User.Identity.IsAuthenticated)
{
throw new ApplicationException("please Login In");
}
return "Hello "+HttpContext.Current.User.Identity.Name;
}
}
Default8.aspx Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default8.aspx.cs" Inherits="Default8" %>
<!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 runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager runat=server ID="aaa" ScriptMode=Debug>
<Services>
<asp:ServiceReference Path="WebService7.asmx" />
</Services>
</asp:ScriptManager>
<mce:script language=javascript type="text/javascript"><!--
function GetMessage()
{
WebService7.HelloWorld(getresult);
}
function getresult(result)
{
alert(result);
}
// --></mce:script>
<input id="Button1" type="button" value="button" on
相关文档:
在最近开始将AJAX技术加入到日常的开发工作中。我在最近写了个AJAX的无刷新登陆且动态添加服务器控件的工作,我将此功能告诉大家希望对大家的工作有所帮助。如果大家有更好的方法且愿意在此留言让我也可以分享到你的成果。
首先在页面中的HTML标记中加入控件UpdatePanel和两个Textbox一个Button:
<asp:UpdatePanel ID ......
var Ajax = new Object;
Ajax.Sysch = function(url) {
var req;
var result = "";
//document .write ("hello")
if (window.XMLHttpRequest) {
//代码段1
// 非IE浏览器
req = new XMLHttpRequest();
//alert(req);
//req.setReque ......
Html代码:
<%@ page language="java" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>jquery ajax</title>
<link rel="stylesheet" type="text/css" media="screen"
......
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!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 runat=" ......
jQuery是一个可以简化 JavaScript?以及AJAX(Asynchronous JavaScript
+XML,异步Javascript和XML)编程的Javascript库。不同于其他的Javascript库,jQuery有他自己的哲学,使你可
以很简单的编写代码。这篇文章就会带领你见识一下jQuery的哲学,探讨一下他的特性以及功能,并且会做一些ajax的示例,以及如何使用plug-
......