簡體   English   中英

重建ASMX Web服務期間出錯

[英]Error during rebuilding ASMX Web Service

我正在嘗試發布我的Web服務,我已經將.asmx文件的“生成操作”屬性更改為“編譯”,將Web.config更改為“無”,但是在嘗試重建解決方案時仍然出現以下錯誤:

Error   1   Keyword, identifier, or string expected after verbatim specifier: @ \MyVirtualCartWS\MyVirtualCartWS.asmx

Error   2   A namespace cannot directly contain members such as fields or methods   \MyVirtualCartWS\MyVirtualCartWS.asmx

這兩個錯誤都指向.asmx文件,因此它是:

<%@ WebService Language="C#" CodeBehind="MyVirtualCartWS.asmx.cs" Class="MyVirtualCartWS.MyVirtualCartWS" %>

后面的代碼

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Collections;


namespace MyVirtualCartWS
{
    /// <summary>
    /// Summary description MyVirtualCartWS
    /// </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 MyVirtualCartWS : System.Web.Services.WebService
    {

        #region Using LoggedUser

        [WebMethod]
        public LoggedUser AddUser(string _login, string _email, string _password)
        {
            LoggedUser lUser = new LoggedUser();
            lUser.AddUser(_login, _email, _password);
            return lUser;
        }

        [WebMethod]
        public LoggedUser LogIn(string _login, string _password)
        {
            LoggedUser lUser = new LoggedUser();
            lUser.LogIn(_login, _password);
            return lUser;
        }

        #endregion
    }
}

該行:

[System.Web.Script.Services.ScriptService]

應該先取消注釋。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM