Opening the file as a New Process

I am trying to open a file, e.g. a text, .doc or .mpp file, when it runs on the localhost system opens a respective file, but when installed in the IIS 5.1 and IIS 6.0 as a virtual directory, and access the file, system doesn't opens...................................................

Imports System.IO

Imports System.Diagnostics

Partial Class CR

Inherits System.Web.UI.Page

Dim projectPath As String

Dim documentPath As String

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

documentPath = "Change Requests\"

projectPath = ConfigurationManager.AppSettings("projectDocumentPath") & Request.QueryString("pid") & "\"

Dim directory As DirectoryInfo

directory = New DirectoryInfo(projectPath & documentPath)

If directory.Exists() Then

Dim files As Array

files = directory.GetFiles()

Dim index As Integer

index = 0

If files.Length > 0 Then

Dim file As FileInfo

Dim tCell As TableCell

Dim tRow As TableRow

Dim documentLink As LinkButton

Dim aLink As HyperLink

Do While index < files.Length

tRow = New TableRow

tCell = New TableCell

file = files(index)

'aLink = New HyperLink

'aLink.NavigateUrl = projectPath & documentPath & file.Name

'aLink.ID = "A" & index

'aLink.Text = file.Name

''AddHandler aLink.PreRender, AddressOf OpenDocument

'tCell.Controls.Add(aLink)

documentLink = New LinkButton

documentLink.ID = "d" & index

documentLink.Text = file.Name

'documentLink.ResolveUrl(projectPath & documentPath & file.Name)

'documentLink.PostBackUrl = projectPath & documentPath & file.Name

AddHandler documentLink.Click, AddressOf OpenDocument

tCell.Controls.Add(documentLink)

 

tRow.Cells.Add(tCell)

itemsTable.Rows.Add(tRow)

index = index + 1

Loop

Else

 

End If

End If

End Sub

Public Sub OpenDocument(ByVal sender As Object, ByVal e As System.EventArgs)

Dim fName As String = projectPath & documentPath & sender.text

Process.Start(fName)

 

End Sub

end class



Answer this question

Opening the file as a New Process

  • Son

    Hello !!

    In IIS->Directory->properties

    Virtual Directory Tab

    Execute Permission : Scripts and Excutables

    Application Protection: Low(IIS Process)

    in Directory Security TAB

    Authentication Control:

    Integrated Windoes authentication

    in the physical folder;

    everyone has all the right, also inculded the ASPNET

    -------------------------------------------

    is there another way to call the process.

    I was browsing the Blog... it says @"file-name"

    but this doesn't work with VB, works as C#, if that is the solution, How to handle in VB

    thanks..............


  • Smitha

    I can do other stuff, enter data and persist to SQL Sever everything else is working fine, even the Active directory authentication is work fine.... In this application for a specific page opens the existing file at a specific location is not working some how.
  • corradMSDN

    I am not sure where the path is going to by the code sample...but...It may be a security issue. Since the process is running as the ASP.NET identity it is not allowed to view outside the directories in the web site. Place the document in a location where it does have access and set the permissions appropriately wherever the location is.... Avoid hard coded pathing. Good luck.


  • abid1pak

    As you have found, that points to the specific page problem and not a directory or IIS issue, per-se.

    Maybe rebuild the page on a new address, but piece by piece until you discover when it fails...good luck.


  • quicksilverm26

    The directory has the access, files are getting uploaded in the same directory, IE keeps trying... even in the task manger a process image name starts e.g. for .doc file WINWORD, notepad.exe for text file .. but it doen't open... thanks any way.. I am assuming it might be a secutiry but I don't know how to resolve
  • Dan Jones MSFT

    The @"XXXX" only tells the compiler to treat it as a literal. You can achieve the same effect by escaping the hot buttons. For example:

    "C:\test\it.txt"

    change it to

    "C:\\test\\it.txt"




  • TedWagner

    If you create a helloworld html page at the virtual location, can you browse to it in IE If you can't that might give you a clue. Good luck.


  • martan

    when run as a local host as show in the link below the same function works

    http://localhost:4080/DashboardDev/CR.aspx pid=S303

    and when used at a server address ,,,,doesn;t

    http://atuedmpc236504/testait/CR.aspx pid=S303

    there the same application is deployed as a virtual directory(testait) in IIS doesn't work.


  • Killjoyrules

    Take a look at the directories/Virtuals in IIS. Right click the virtual and do properties. From there you will be presented with many different flavors of security. You may want to allow the web site to have read and write access as found on the Virutal Directory page. Also on that page you may have to racket down Application protection to "Low" and specify Execute Permissions.

    You can check the directory permissions, IE granting ASP.NET process access in the file explorer, properties ->Security tab. Good Luck.


  • Opening the file as a New Process