代码在调试模式下工作但在IE中没有 [英] code working in debug mode but not in IE

查看:202
本文介绍了代码在调试模式下工作但在IE中没有的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





当我在本地调试时,它的工作和文件正在打开,但是当我尝试从IE或其他任何远程机器上显示的URL时列表框的内容但是当我点击任何文件时,它会进行回发但不会打开文件。我使用以下代码:



Hi,

When i debug in local its working and file is getting opening, but when i try the url from IE or from any other remote machine its displaying the contents of list box but when i click any file, it goes to postback but does not open the file. I am using the below code:

Imports System.IO
Imports System.Net
Imports System.Diagnostics.Process
Public Class _Default
Inherits System.Web.UI.Page Dim path As String = ConfigurationManager.AppSettings("filepath") Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Try
If (Not IsPostBack) Then
Dim di As DirectoryInfo = New DirectoryInfo(path)
Dim fidir As FileInfo() = di.GetFiles()
Dim fi As FileInfo
For Each fi In fidir lstbx_file.Items.Add(fi.Name)
Next
End If
Catch ex As System.IO.IOException
End Try
End Sub
Protected Sub lstbx_file_SelectedIndexChanged(sender As Object, e As EventArgs) Handles lstbx_file.SelectedIndexChanged
Try Dim fname As String fname = System.IO.Path.Combine(path,lstbx_file.SelectedValue.ToString())
Dim p As Process = Process.Start("notepad.exe", fname)
p.WaitForExit(999999999)
p.Dispose()
Catch ex As Exception
End Try
End Sub
End Class

推荐答案

Dim p As Process = Process.Start("notepad.exe", fname)





如果你声明它在本地运行时工作正常 - 那么这一行就是你的问题。



这句话创造了一个新的过程Web服务器 - 因此当远程用户运行此服务器时,会尝试在Web服务器上打开记事本(即 - 不在远程用户PC上。



在本地运行它的原因是Web服务器和客户端PC是相同的。 />


...要让远程用户查看此文件的内容,您需要在Web服务器上打开该文件并将文件内容流回远程用户。



看看 * here * 表示方法。



希望这有帮助。



If, as you state it works fine when your running locally - then this line will be your problem.

This statement creates a new process on the web server - so when when remote users run this, an attempt to open notepad on the web server is made (i.e. - not on the remote users PC).

The reason why it works when you run it locally, is the web server and the client PC are the same.

... for remote users to view the contents of this file, you would need to open the file on the web server and stream the file contents back to the remote users.

Have a look * here * for an approach.

Hope this helps.


这篇关于代码在调试模式下工作但在IE中没有的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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