ashx需要编译吗_如何动态编译一个ashx文件?

bd96500e110b49cbb3cd949968f18be7.png

I have a ashx file in a asp.net web project. It has a code behind cs file. The cs file is compiled into project dll & deployed to production. I found no way to dynamically change the cs file without deploying the whole project dll.

I have been putting c# code into aspx (not .cs) file, after deployment, I can make change to a single aspx file, and deploy, IIS can dynamically compile & merge with its code behind c# code.

Can I do the similar thing with ashx file?

ASP.NET supports the dynamic compilation of ASP.NET pages (.aspx files), ASP.NET Web services (.asmx files), ASP.NET HTTP handlers (.ashx files)

thanks, this can save me lots of time!

解决方案

I figured it out.

add a Generic handler - Handler1.ashx in visual studio

delete the cs file which auto-created.

open ashx again,

remove CodeBehind="Handler1.ashx.cs"

add c# code below

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

public class Handler1 : IHttpHandler

{

public void ProcessRequest(HttpContext context)

{

context.Response.ContentType = "text/plain";

context.Response.Write("Hello World2");

}

public bool IsReusable

{

get

{

return false;

}

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值