[英]web service in asp.net
我想為“注冊”頁面或數據庫連接創建一個Web服務。
我已經完成數據庫連接
但是我無法獲得如何在Web服務中設計注冊頁面的方法..因為Web服務中沒有界面。
請告訴我
我的網絡服務代碼是:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Data;
using System.Data.SqlClient;
namespace WcfService1
{
/// <summary>
/// Summary description for WebService1
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class WebService1 : System.Web.Services.WebService
{
string Connection = "Data Source=SHUMAILA-PC;Initial Catalog=kse;User ID=sa;Password=sa";
[WebMethod]
public void SQLconn()
{
SqlConnection DataConnection = new SqlConnection(Connection);
// the string with T-SQL statement, pay attention: no semicolon at the end of //the statement
string Command = "INSERT INTO login VALUES ('hina','me12')";
// create the SQLCommand instance
SqlCommand DataCommand = new SqlCommand(Command, DataConnection);
// open the connection with our database
DataCommand.Connection.Open();
// execute the statement and return the number of affected rows
int i = DataCommand.ExecuteNonQuery();
//close the connection
DataCommand.Connection.Close();
}
}
}
但是我無法獲得如何在Web服務中設計注冊頁面的方法..因為Web服務中沒有界面。
實際上,您的推理是正確的。 ASMX Web服務實現SOAP協議,並且不能具有任何GUI接口。 在.NET的頂部設計Web應用程序的界面,例如可以使用ASP.NET。 因此,您可以創建一個將使用此Web服務的ASP.NET應用程序。 順便說一下,ASX Web服務被視為已棄用的技術,您應該改為使用WCF。
有不同的技術。 但是,通過AJAX對Web方法利用Ajax請求是常見的。
這是一個較舊的演練,但仍然有效-http://dotnetslackers.com/articles/ajax/Using-jQuery-with-ASP-NET.aspx
它演示了使用jQuery(我推薦)和Microsoft Ajax的兩種方法。
這里有一些更不錯的鏈接-
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.