【www.gdgbn.com--安卓教程】

<%@ webhandler language="c#" class="producthandler" %>

using system;
using system.web;
using jbtcard.entity.companyentity;
using jbtcard.business.companybs;
using system.collections.generic;
using newtonsoft.json;
using system.web.sessionstate;

public class producthandler : ihttphandler, irequiressessionstate, ireadonlysessionstate{
   
    public void processrequest (httpcontext context) {
string moduleid = context.request.form["moduleid"].tostring();
string message = "";
switch (moduleid)
{
case "getptypelist":
ilist list = producttypebs.getptypelistidname();
message = 网页特效convert.serializeobject(list);
break;
case "getcompanybyid":
int cid = convert.toint32(context.session["cid"]); companyentity company = companybs.getcompanyentybyid(1);
message = javascriptconvert.serializeobject(company);
break;
case "insert":
string condis = context.request.form["condi"].tostring();
productentity model = (productentity)javascriptconvert.deserializeobject(condis, typeof(productentity));

bool b = productbs.addproduct(model);
if (b)
{
message = "{success:true}";
}
else
{
throw new exception("商品添加失败!");
}
break;
}
context.response.contenttype = "text/javascript";
context.response.write(message);
    }

    public bool isreusable {
        get {
            return false;
        }
    }

}

本文来源:http://www.gdgbn.com/shoujikaifa/28725/