Make sure that the project should be as minimum as possible.
"And whoever is removed away from the Fire and admitted to Paradise, he indeed is successful." (The Holy Quran)
Excellent Windows VPS Hosting Imran Baloch MVP, MVB, MCP, MCTS, MCPD
Not 404,the page runs well but shows me a red cross in the position of "<img>"……:(
Take your code that creates the images and instead of send it back from a http request, save it to disk and then try to open it with a image viewer. I'm guessing it's something to do with how you create the image, not how you serve it over http.
Just feeling curious that if I use a generic handler—— ashx,everything goes fine with me;But when I use a common C# class in the form of library……Nothing happens:(
"And whoever is removed away from the Fire and admitted to Paradise, he indeed is successful." (The Holy Quran)
Excellent Windows VPS Hosting Imran Baloch MVP, MVB, MCP, MCTS, MCPD
Marked as answer by TimoYang on May 06, 2012 08:27 AM
TimoYang
Contributor
3732 Points
1275 Posts
How to handle "Httphandler" in MVC?
May 05, 2012 01:45 AM|LINK
Sorry I have to post a duplicated Issue because this problem hasn't been solved yet……
Considering somebody such as MSFT——Yangyang tells me that he cannot reproduce the issue……I'd like to repeat the problem again:-)
and here's my step:
1. Create a ClassLibrary file to inherit the class from the interface:IHttpHandler,and then write this in the Requestprocess method:
Bitmap bt = new Bitmap(20,20); Graphics g = Graphics.FromImage(bt); g.DrawString("1234",SystemFonts.DefaultFont,Brushes.Red,new PointF(0,0)); g.Dispose(); bt.Save(context.Response.OutputStream,ImageFormat.Jepg);2. Then create an MVC proj after referring this compiled dll file,and in the root,find out the web.config and do this:
3. In the end,in the View page,do this:
<img src='xyz.req'/>
4. Run the MVC proj,I can see the blank img:BUT THIS CODE WORKS WELL IN THE FORM OF HTTPHANDLER(*.ASHX)……Why?
Thxxxxxxxxxx anyway!
BrockAllen
All-Star
27516 Points
4897 Posts
MVP
Re: How to handle "Httphandler" in MVC?
May 05, 2012 02:13 AM|LINK
So you get a 404? The type needs to be fully qualified like this:
DevelopMentor | http://www.develop.com
thinktecture | http://www.thinktecture.com/
Rameshsoft
Member
4 Points
4 Posts
Re: How to handle "Httphandler" in MVC?
May 05, 2012 03:17 AM|LINK
What is the use of HTTPhandler in MVC?
TimoYang
Contributor
3732 Points
1275 Posts
Re: How to handle "Httphandler" in MVC?
May 05, 2012 05:43 AM|LINK
Not 404,the page runs well but shows me a red cross in the position of "<img>"……:(
imran_ku07
All-Star
45815 Points
7698 Posts
MVP
Re: How to handle "Httphandler" in MVC?
May 05, 2012 01:22 PM|LINK
PLease share me a sample project at
imran_ku07 at yahoo.com
Make sure that the project should be as minimum as possible.
Excellent Windows VPS Hosting
Imran Baloch MVP, MVB, MCP, MCTS, MCPD
BrockAllen
All-Star
27516 Points
4897 Posts
MVP
Re: How to handle "Httphandler" in MVC?
May 05, 2012 01:34 PM|LINK
Take your code that creates the images and instead of send it back from a http request, save it to disk and then try to open it with a image viewer. I'm guessing it's something to do with how you create the image, not how you serve it over http.
DevelopMentor | http://www.develop.com
thinktecture | http://www.thinktecture.com/
TimoYang
Contributor
3732 Points
1275 Posts
Re: How to handle "Httphandler" in MVC?
May 06, 2012 06:24 AM|LINK
Hello BrockAllen——Thanks you are very kind:-)!
Just feeling curious that if I use a generic handler—— ashx,everything goes fine with me;But when I use a common C# class in the form of library……Nothing happens:(
Why???
TimoYang
Contributor
3732 Points
1275 Posts
Re: How to handle "Httphandler" in MVC?
May 06, 2012 06:27 AM|LINK
Oh dear mvp!Many thanks
Now I've sent it to you,plz accept it……:D
Chatting with you……;D
imran_ku07
All-Star
45815 Points
7698 Posts
MVP
Re: How to handle "Httphandler" in MVC?
May 06, 2012 07:09 AM|LINK
You are only missing this in global.asax,
routes.IgnoreRoute("{resource}.req/{*pathInfo}");
Excellent Windows VPS Hosting
Imran Baloch MVP, MVB, MCP, MCTS, MCPD
TimoYang
Contributor
3732 Points
1275 Posts
Re: How to handle "Httphandler" in MVC?
May 06, 2012 08:27 AM|LINK
Hi imran_ku07!
Many many thanks!I don't know how to be grateful to you!
Just feeling curious——Why should I add this?And if I use ashx,why don't I need to do that?
Reguards!