简体   繁体   English

asp.net中的Web服务

[英]web service in asp.net

I want to create an web service for 'sign up' page or database connectivity.. 我想为“注册”页面或数据库连接创建一个Web服务。

I am done with database connectivity 我已经完成数据库连接

but i am unable to get how ca i design an sign up page in web service.. as there is no interface in web service. 但是我无法获得如何在Web服务中设计注册页面的方法..因为Web服务中没有界面。

Please tell me 请告诉我

my web service code is : 我的网络服务代码是:

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();

        }

    }
}

but i am unable to get how ca i design an sign up page in web service.. as there is no interface in web service. 但是我无法获得如何在Web服务中设计注册页面的方法..因为Web服务中没有界面。

In fact your reasoning is correct. 实际上,您的推理是正确的。 An ASMX web service implements the SOAP protocol and cannot have any GUI interface whatsoever. ASMX Web服务实现SOAP协议,并且不能具有任何GUI接口。 Top design an interface of a web application in .NET you could use ASP.NET for example. 在.NET的顶部设计Web应用程序的界面,例如可以使用ASP.NET。 So you could create an ASP.NET application which will consume this web service. 因此,您可以创建一个将使用此Web服务的ASP.NET应用程序。 By the way ASX web services are considered as deprecated technology and you should use WCF instead. 顺便说一下,ASX Web服务被视为已弃用的技术,您应该改为使用WCF。

There are different techniques. 有不同的技术。 However, its common to utilize Ajax requests to your webmethod via AJAX. 但是,通过AJAX对Web方法利用Ajax请求是常见的。

Here is an older walk-through but its still valid - http://dotnetslackers.com/articles/ajax/Using-jQuery-with-ASP-NET.aspx 这是一个较旧的演练,但仍然有效-http://dotnetslackers.com/articles/ajax/Using-jQuery-with-ASP-NET.aspx

It demonstrates two approaches using jQuery (which I recommend) and Microsoft Ajax. 它演示了使用jQuery(我推荐)和Microsoft Ajax的两种方法。

Here are some more decent links - 这里有一些更不错的链接-

http://www.asp.net/ajaxlibrary/jquery_dibs.ashx http://www.asp.net/ajaxlibrary/jquery_dibs.ashx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM