问题描述
- 在ashx上传图片后,ashx就不能编了?
-
这是winform上的代码
private void button2_Click(object sender, EventArgs e)
{
System.Net.WebClient myWebClient = new System.Net.WebClient();
OpenFileDialog of = new OpenFileDialog();
if (of.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
FileInfo fileinfo = new FileInfo(of.FileName);} string fileName = of.FileName; myWebClient.UploadFile("file:///E:\TEST\testclient\HandleUpImage.ashx", "POST", fileName ); MessageBox.Show("ooooook"); }
//这是原本ashx上的代码
public class Uploader : IHttpHandler7.{
8. public void ProcessRequest(HttpContext hc)
9. {
10. foreach (string fileKey in hc.Request.Files)
11. {
12. HttpPostedFile file = hc.Request.Files[fileKey];
13. file.SaveAs(Path.Combine(hc.Server.MapPath("."), file.FileName));
14. }
15. }
16.
17. public bool IsReusable
18. {
19. get { return true; }
20. }
21.}
点击了按钮 ,再用ie打开ashx显示上传图片是成功的,但是我再用VS2010打开ashx,里面就不是代码了,而是这样的
这是正常的吗 那我不能再用这个ashx的文件了?要用只能将这些全部删掉 重新写代码?
解决方案
怎么感觉你上传的文件内容写入到ashx里面了。。而且file:///E:TESTtestclientHandleUpImage.ashx你这种路径也有问题吧。。无法编译吧。。
时间: 2024-08-30 12:48:48