Search code examples
c#asp.netiischmhtml-help-workshop

open .chm file in ASP.NET


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?


Solution

  • 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.)