473,599 Members | 3,118 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

IHttpHandler problem

Hi;

I just wrote my first IHttpHandler and am having a problem. If the content
type is "text/html" then the below code works fine. But if it's "text/plain"
then my browser gets:
The XML page cannot be displayed
Cannot view XML input using style sheet. Please correct the error and then
click the Refresh button, or try again later.
--------------------------------------------------------------------------------

Invalid at the top level of the document. Error processing resource
'http://localhost:3179/portal/ShowReport.aspx '. Line 1...

hi there
^

url is: http://localhost:3179/portal/ShowReport.aspx

code (App_Code\ShowR eport.cs) is:
using System.Web;

/// <summary>
/// Summary description for ShowReport
/// </summary>
public class ShowReport : IHttpHandler
{
public ShowReport()
{
}

#region IHttpHandler Members

public bool IsReusable
{
get { return false; }
}

public void ProcessRequest( HttpContext context)
{

context.Respons e.ContentType = "text/plain";
context.Respons e.Write("hi there");
}

#endregion
}

web.config is:
<httpHandlers >
<add verb="*" path="ShowRepor t.aspx" type="ShowRepor t"/>
</httpHandlers>

???

--
thanks - dave
david_at_windwa rd_dot_net
http://www.windwardreports.com

Mar 22 '06 #1
1 1280
Hi Dave,

I think the problem is that the response stream has not be eneded after you
finishing write out the content. then, the runtime may add some additional
http headers which cause the client browser fail to parse it. You can call
the response.End() to end the response stream after you finishing the
content outputing. e.g:

public void ProcessRequest( HttpContext context)
{
context.Respons e.ContentType = "text/plain";
context.Respons e.Write("hi there");

context.Respons e.End();

}

Hope this helps.

Regards,

Steven Cheng
Microsoft Online Community Support
=============== =============== =============== =====

When responding to posts, please "Reply to Group" via your newsreader so
that others may

learn and benefit from your issue.

=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.


Mar 22 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1459
by: lapin | last post by:
I'm trying to get access to session variables from an IHttpHandler class. In several places I've seen the solution posted as in this message: >If you define your own custom HttpHandler, you need to >import the >System.Web.SessionState namespace, you >need it to implement the IRequiresSessionState interface >if you want it to >have a session instance :P
1
3077
by: lapin | last post by:
I'm trying to get access to session variables from an IHttpHandler class. In several places I've seen the solution posted as in this message: >If you define your own custom HttpHandler, you need to >import the >System.Web.SessionState namespace, you >need it to implement the IRequiresSessionState interface
13
4295
by: Sky Sigal | last post by:
I have created an IHttpHandler that waits for uploads as attachments for a webmail interface, and saves it to a directory that is defined in config.xml. My question is the following: assuming that this is suppossed to end up as a component for others to use, and therefore I do NOT have access to their global.cs::Session_End() how do I cleanup files that were uploaded -- but obviously left stranded when the users aborted/gave up writting...
5
1999
by: vimakefile | last post by:
I'd like to have the concept of a Page (different code-behind file for each url, session state, etc.) but be able to specify my own custom HTTP payload. (I don't want to use any Asp.Net forms, controls, etc.) (Happens to be binary - but although I need to use HTTP, it's not going to a browser.) With IHttpHandler I lose Url->page mapping and sessions, but with Page I don't have a way to override the HTTP processing, do I? I'd expect...
0
1056
by: Stu | last post by:
Hi, I am trying to write a basic httphandler to 'fake' that pages actually exist. I have copied the code below from various sites - but the line 'Implements IHttpHandler' reports an error "type 'IHttpHandler' is not defined". Any ideas what am I doing wrong? Thanks in advance,
24
2740
by: John Rivers | last post by:
ASPX which means ASPX pages, the code-behind concept, User Controls, Web Controls etc. is very poorly designed and makes it extremely hard to develop professional quality web applications. ASPX is Microsoft's attempt to "dumb down" web application development to help unskilled developers such as web design agencies achieve some results. For high quality applications IHttpHandlers are the way to go.
5
1696
by: shapper | last post by:
Hello, In this moment I am creating all my aspx pages on my vb.code at runtime. It seems nonsense to have .aspx and .aspx.vb files in my projects. I am considering creating my pages on the fly using IHttpHandler. I already did that for delivering XML files.
1
4307
by: Aartware | last post by:
I've read all the items about the IHttpHandler and the session-object and I see nothing wrong with my code, but still I have no session object. This is my code: Imports System Imports System.Data Imports System.Web imports System.Web.SessionState Imports System.Web.UI
0
1190
by: shapper | last post by:
Hello, I am using an ASP.NET 3.5 SP1 and a while ago I created an IHttpHandler that transforms a Sitemap XML file to a compatible Google Sitemap (https://www.google.com/webmasters/tools/docs/en/ protocol.html#sitemapXMLExample) XML file using a XSD file. Now I need to do something similar but I need to create the XML file from scratch using data that I am getting from an SQL database using linq.
0
7992
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8398
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8400
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8267
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6725
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5850
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3898
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2414
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1250
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.