open .chm file in ASP.NET

2.2k views Asked by At

I'm using below code to open help file in asp.net

protected void lblHelp_Click(object sender, EventArgs e)
{
    string filepath = Server.MapPath(@"VersionControlHelp.chm");    
    Process.Start(filepath);
}

this works perfectly in my local machine but not working when i published to the IIS server. are there any IIS settings that i should modify?

3

There are 3 answers

0
tomfanning On BEST ANSWER

If you call Process.Start() on the web server, you will get the CHM file opening on the server, in the context of the IIS application pool user, which has no console attached (so nothing will happen).

I'm certain this is not what you want.

I think you are attempting to open the CHM file on the client machine. To do this, call Response.Redirect("pathto/yourchmfile.chm") from within your lblHelp_Click method. That will cause the browser to download the CHM file, and the user will then have the option of opening it (subject to browser warnings) or saving it. I think that's about as close as you'll get.

(By the way, it works locally because the ASP.NET development server bundled with Visual Studio is just a system tray application, loaded at user login - so if this issues a Process.Start(), the CHM file will be opened in the context of the user running Visual Studio, i.e. you, attached to a console session, i.e. your screen.)

0
codingbiz On

If this already worked locally, then it might be because of permission or incorrect path. If you are catching the exception silently, you may not see the error e.g. Access denied, Path not found

If the file is in the root of your web application, you can try this

protected void lblHelp_Click(object sender, EventArgs e)
{
    string filepath = Server.MapPath("~/VersionControlHelp.chm");    
    Process.Start(filepath);
}

Also, the @ is symbol is not needed since you were not using backslash (\) or any special character

0
Edi Wang On

the Process.Start may need enough previlege to run. so you need to check the current application pool identity of your website, is this have enought previlege to start a process on the server?