按钮单击事件在本地有效,但在发布到服务器时无效 [英] button click event works locally but not when published to a server

查看:56
本文介绍了按钮单击事件在本地有效,但在发布到服务器时无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个按钮,将网页另存为html文件,并提示用户将其保存.当我在本地测试它时,它工作正常,但是当我将其发布到测试服务器时,出现以下错误:

I created a button that saves the webpage as an html file and prompts the user to save it. It works fine when I am testing it locally, but when I publish it to the test server, I get the following error:

The remote server returned an error: (401) Unauthorized. 



代码如下:



The codeis as follows:

Protected Sub btnSaveAsHtml_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSaveAsHtml.Click

<pre>Dim url As String
        url = "http://test.intranet.company.com/ESTaxCalculator/"
        Dim wc As System.Net.WebClient = New System.Net.WebClient
        ''wc = Nothing
        Dim path As String
        path = "C:\inetpub\temp\"
        Dim filename2 As String
        filename2 = "E&Shtml.html"
        wc.DownloadFile(url, path + filename2)
        Response.ClearContent()
        Response.ClearHeaders()
        Response.AddHeader("ContentType", "application/octet-stream")
        Response.AddHeader("Content-Disposition", "attachment;   filename=E&Shtml.html")
        Response.WriteFile(path + filename2)
        Response.End()



用于本地测试的URL与现在的URL不同.

我在其他地方搜索过,但找不到任何对我有帮助的东西.我将不胜感激.

谢谢.



The url for testing locally is different than what is there now.

I have searched elsewhere but am unable to find anything that has helped me yet. I would appreciate any guidance.

Thank you.

推荐答案

我结束了更改捕获当前网页的方式,并且现在可以正常工作了.
I ended changing how I was capturing the current web page and it is working now.


这篇关于按钮单击事件在本地有效,但在发布到服务器时无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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