分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 运营维护

cathome 猫家 开发日记-webservice服务 ,生成json.

发布时间:2023-09-06 02:21责任编辑:蔡小小关键词:jsjsonwebservice

概述,采用熟悉的c# 语言。

1.用asmx 。微软的web服务的标准格式。方便。

2.由方法生成json字符。只是利用ms 的框架而已。

配置文档。

<?xml version="1.0" encoding="utf-8"?><!-- ?有关如何配置 ASP.NET 应用程序的详细信息,请访问 ?http://go.microsoft.com/fwlink/?LinkId=169433 ?--><configuration> ?<system.web> ???<compilation debug="true" targetFramework="4.5" /> ???<httpRuntime targetFramework="4.5" /> ???<webServices> ?????<protocols> ???????<add name="HttpPost"/> ???????<add name="HttpGet"/> ?????</protocols> ???</webServices> ?</system.web> ?<connectionStrings> ???<add name="dbstr" connectionString="Data Source=localhost;Initial Catalog=mycity;User ID=sa;Password="/> ?</connectionStrings></configuration>

方法

 /// <summary> ???/// WebService1 的摘要说明 ???/// </summary> ???[WebService(Namespace="mycity")] ???[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] ???[System.ComponentModel.ToolboxItem(false)] ???[System.Web.Script.Services.ScriptService] ???public class MainPage : System.Web.Services.WebService ???{ ??????//商家的大类 ???????[WebMethod(Description = "商家的大类")] ???????public void Category_MainCategory() ???????{ ???????????List<Model.VCategory_All> category = bll_category.GetModelList("cg_fatherid=‘0‘"); ???????????string jasonCategory = Function.ConvertJson.ListToJson(category); ???????????Context.Response.Write(jasonCategory); ???????????Context.Response.End(); ???????}

cathome 猫家 开发日记-webservice服务 ,生成json.

原文地址:https://www.cnblogs.com/lsfv/p/9921807.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved