Recently I had faced the problem to add HTTP handler file in
web.config file. I have a requirement to restrict my document file, so I have
create http handler for the document, But when I try to register the file I got
the below error.
Parser Error
Message: Could not load file or assembly 'DocHandler'
or one of its dependencies. The system cannot find the file specified.
Then I goggled to find the solution for the problem, after
doing deep search I got one solution that use class instead of handler file.
Then I follow the below steps to solve my issues.
1. i create separate class file in the name of Dochandler.cs
2. Create namespace for the class file Dochandler
3. Then I interface IHttpHandler, and I use same code wheich I used in the handler.
4. I saved the filein App_code directory.
Next in web.config file you have to code like
below in httpHandlers tag
<add verb="*" path="*.doc" type="DocHandler.DocHandler,App_Code"/>
|
Here Verb indicates Get Request and Post Request
(* allows the both)
Path indiactes the follow the extension type.
Type indiactes filename and the directory
That’s it Now you can run the project it will
works likecharm………
Post your comments if its useful to you……..
0 comments:
Post a Comment