如何在Web项目的app_code文件夹中创建Web服务类 [英] How to create the web services class in app_code folder in Web Project

查看:164
本文介绍了如何在Web项目的app_code文件夹中创建Web服务类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我有一个solution_Prj,并且有4个项目的解决方案(BALLibrary,DALLibrary,Entity,WebProject1)

<在WebProject1中添加一个已成功添加到我的webproject1中的Web服务。我的网站sesrvies名称为webservices.asmx。我的问题是如何在App_code中添加带有webservices(徽标)的webservies.cs类。



在新网站中

自动生成webservices.cs app_code中的类。那么如何使用WebProject在app_code文件夹中生成webservices.cs类



请帮帮我



感谢你

解决方案





一般来说,如果添加服务项目,它会要求添加它在app_code文件夹中,所以,它没有问,它很好。你只需要在web应用程序中添加一个类文件,它将在app_code文件夹中创建。



继承具有Service类的类并向其添加必要的Web服务属性如下所示。

 [WebService(Namespace =   http ://tempuri.org/)] 
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// 要允许使用ASP.NET AJAX从脚本调用此Web Service,请取消注释以下行。
[System.Web.Script.Services.ScriptService]
public class Class1:System.Web.Services.WebService
{
public Class1()
{
}
}





并修改asmx文件中的代码和类属性,如下所示。

< pre lang =HTML> <%@ WebService 语言 = < span class =code-keyword> C# CodeBehind = 〜/ App_Code / Class1.cs = Class1 %>





希望它有所帮助。


Hi all,

I have one solution_Prj and under soluations having 4 projects( BALLibrary,DALLibrary,Entity,WebProject1)

in WebProject1 add one web services successfully added in my webproject1. my web sesrvies name webservices.asmx. my question is how to add webservies.cs class in App_code with webservices(logo).

In new website
automatically generate webservices.cs class in app_code. so how to generate webservices.cs class in app_code folder using WebProject

please help me

thanking u

解决方案

Hi,

generally, if you add a service project, it will ask to add it in app_code folder, so, it did''nt asked, its fine. you just add one class file to the web application, that will create in app_code folder.

inherit that class with "Service" class and add necessary web service attributes to that like below.

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// 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 Class1 : System.Web.Services.WebService
{
    public Class1()
    {    	
    }
}



and modify the code behind and class attributes in asmx files like below.

<%@ WebService Language="C#" CodeBehind="~/App_Code/Class1.cs" Class="Class1" %>



hope it helps.


这篇关于如何在Web项目的app_code文件夹中创建Web服务类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆