Can Return Multiple Content Types Per One HTTP Request
Jul 31, 2010
Reporting system has list of available reports on a web page. When user clicks on a report new browser window opens, server starts to prepare report (winword document) and then sends it back after 2-10 seconds.
Code in the handler looks like the following:
context.Response.AddHeader("Content-Disposition",
"attachment;filename=report.doc");
context.Response.BinaryWrite(reportDocument);
Is it possible to prepare html content immediately send it back and then continue with time-consuming report preparation not closing connection?
View 3 Replies
Similar Messages:
Apr 16, 2012
I am trying to the following to return xml response from an http request
Code:
Try
Dim id As String = Request.QueryString("id")
Dim xmlOut As String = ""
cn.ConnectionString = "Data Source=192.168.1.2;Initial Catalog=db;Persist Security Info=True;User ID=sa;Password=pass"
dad = New SqlDataAdapter("select * from tbl where id = '" & id & "'", cn)
ds.Clear()
[Code] ...
Is there some other way to do this without having to resort to writing the xml to a temp file on C drive and reading it again to display the output ?
View 2 Replies
Oct 13, 2010
I have two methods that do the similar thing. There are small differences here and there, which I can control by passing arguments to them when I call them, so I can effectively merge them. However one returns a string, and the other one an ArrayList. On the top of my head, I could merge them and return an Object, and then get the information I need. Is there a way though to return multiple types in the method's signature? What's the proper way to implement this?
View 5 Replies
Dec 30, 2010
I am passing some data in HTTP body using the Ajax request. These contents on server are accessible using Request.InputStream. Now i want to write it to file on server disk Asynchronously. How to do that ?
If the data sent using the HTTP is more then i don't want server application to die/get affected. So that i would like to write it Asynchronously.
Following is sample for reference regarding what i am trying to do ...
System.IO.Stream str;
// Create a Stream object.
str = Request.InputStream;
// TO DO Write it to file asyncronously ...
str.Write(someFile, 0, strLen);
View 3 Replies
Dec 6, 2010
When I use WatiN to go to a specific web page, how can I fake the HTTP referrer with a query string (i.e. request is from google search with query string q=search_term)? So I can verify that the response header has the 301 redirect for specific referrer URL.
View 2 Replies
Jul 15, 2010
i redirect a page from http to https using http module begin request handler .i am calling webservice using ajax but it is saying webserice not defined .which otherwise works fineits work fine when rediect page in page_load instead .but i need to add function for https to http in every page. i still not know why ajax is not working when i use http module for redirect
View 3 Replies
May 15, 2010
I have a webservice which works 100% fine on my developer machine. Where Web Service is installed on LOCALHOST on my developer machine,Then i went to my servers, I installed webservice on one server and map it with the server where the website is hosted, Then i tried accessing this service using BROWSER from my web server, it worked fine, That means the mapping was done perfect.Then i run my program on web server (website). It worked fine on page1, then on page2, but when i did the same and call same function on page3, It popped me any error of
View 4 Replies
Jan 21, 2010
I there a way to know if a request is a soap request on AuthenticateRequest event for HttpApplication? Checking ServerVariables["HTTP_SOAPACTION"] seems to not be working all the time.
public void Init(HttpApplication context) {
context.AuthenticateRequest += new EventHandler(AuthenticateRequest);
}
protected void AuthenticateRequest(object sender, EventArgs e) {
app = sender as HttpApplication;
if (app.Request.ServerVariables["HTTP_SOAPACTION"] != null) {
// a few requests do not enter here, but my webservice class still executing
// ...
}
}
I have disabled HTTP POST and HTTP GET for webservices in my web.config file.
<webServices>
<protocols>
<remove name="HttpGet" />
<remove name="HttpPost" />
<add name="AnyHttpSoap" />
</protocols>
</webServices>
Looking at ContentType for soap+xml only partially solves my problem. For example,
Cache-Control: no-cache
Connection: Keep-Alive
Content-Length: 1131
Content-Type: text/xml
Accept: */*
Accept-Encoding: gzip, deflate
Accept-Language: ro
Host: localhost
mymethod: urn:[URL]
Some clients instead of having the standard header SOAPAction: [URL], have someting like in example above. "mymethod" represents the method in my web service class with [WebMethod] attribute on it and [URL] is the namespace of the webservice. Still the service works perfectly normal. The consumers use different frameworks (NuSOAP from PHP, .NET, Java, etc).
View 4 Replies
Oct 24, 2010
I develop an asmx web service (i.e. ASP.NET 2.0). There's a piece of code that may read the contents of the HTTP request (via HttpContext.Current.Request.InputStream) while processing it. I realise that InputStream may only be read once for a request, and I make sure I never try to read it more than once.
The problem seems to be that if InputStream happens to be read during the early stages of the application's lifecycle (e.g. after pskill w3wp, during Application_Start), the HTTP request fails with a HTTP 400 - Bad Request error, with no explanation given, no exception thrown and no entry in the httperr log. If it is read later (e.g. within the web method itself), requests run fine whether InputStream is read or not. Application_Start runs fine if InputStream isn't read.
Is this some sort of ASP.NET bug? IIS bug? Or am I doing something wrong by daring to read InputStream? And if so, is there another way to get a look at the "raw" contents of the request without disturbing the inner workings of IIS/ASP.NET? In short, adding this code within Application_Start is enough to reproduce this error: using (StreamReader reader = new StreamReader(HttpContext.Current.Request.InputStream))reader.ReadToEnd();
View 1 Replies
Mar 2, 2011
I have say class/ojbect one which I am returning as details. But then there is a second class that is related to the first that I want to list (and have an option to look at the details). How do I get return both of those?
Example is like in an item as the main piece but there may be details or other items that are related to the main item. I will select them with a linq query but then how do I return them to the same view?
Do I need to have some sort of partial or other form to display the second object type? I don't see where returning the view I can return both.
My thought for right now is to create a new class that contains both of the object types but I know there has to be a better way.
View 3 Replies
Jun 24, 2010
i have 10 employee objects.I want to return these 10 object from a web method to web service client.
View 6 Replies
Jan 25, 2010
I have the following statement, I want to turn it into a Public Shared Function :
If isEmployee Then
Dim employeeInstance As New Employee
employeeInstance = GetEmployeeInstanceByUserId(userId)
Return employeeInstance
Else
Dim studentInstance As New Student
studentInstance = GetStudentInstanceByUserId(userId)
Return studentInstance
End If
Public Shared Function GetWorkerInstance(Byval isEmployee as Boolean) As ...(not sure what to write here)...
There two possible return Type. I'm not sure what I should declare for the function return type.
View 2 Replies
May 27, 2010
If I'm returning an object, then it's pretty straight-forward. However, if I'm just trying to return whether or not the method was successful or not, what's the best option? Sure ... bool seems obvious - but what if you need to debug or get some additional details out of the method than just "yes/no"? Well that's where a string becomes more obvious, right? You can leave it empty to say that the method was successful or chock it full of details in the case of an error. But this can make it less intuitive to others who may have to run your functions and it also jumbles up everything you wanted to pass back into one large string.
View 3 Replies
May 5, 2010
I have .aspx page methods with return type of string, which work great. I am using some jQuery ajax, and some .NET Ajax "PageMethods.methodName" syntax from the client side to successfully call these page methods. I need to return xml from a page method.... I would LOVE to be able to return system.Xml.Linq.XElement type from page method. I get a serialization circular reference error when I attempt to return XElement or XDocument. I don't really want to return XML.ToString() to client, and then convert string to xml in javascript. What return page method return type(s) would allow me to retrieve xml with jQuery ajax call? I know json is the alternative, but will not give me what I need this time.
View 3 Replies
Aug 13, 2010
I am trying to figure out why javascript functions I create with declared return types are not giving me intellisense hints. See code below, specifically updateNextItemTime in Sample.TodoList.
[Code]....
View 9 Replies
Jan 21, 2010
I have one page that checks the content type then either returns an XML or a Plain Text page.
On IE6 (Unfortunately still the corporate standard) viewing XML content works but when I try and view the Plain Text content it reports: The XML page cannot be displayed. Invalid at the top level of the document. Error processing resource.
On Firefox it works perfectly, displaying an XML document for XML content and a plain text document otherwise.
Is this a bug with IE6 caching the content type? The URL is the same but the query string is different for different entries.
Here is the code that generates the output. I have single stepped it and it goes down the Plain Text leg when I expect it to, but IE still reports the XML error:
[Code]....
View 2 Replies
Feb 25, 2010
It uses asp.net (webforms), bunch of jquery plugins and whatnot.
Problem: there's unnecessary HTTP request to localhost/undefined and that makes every request take ~1s longer than needed.
Question: is there any tactic to find guilty code?
Clue: undefined makes me think that there's JS involved.
Firebug log:
GET /undefined HTTP/1.1
Host: localhost:17817
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; lv; rv:1.9.2) Gecko/20100115
Firefox/3.6
Accept: image/png,image/;q=0.8,/*;q=0.5
Accept-Language: lv,en-us;q=0.7,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-13,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Referer: http://localhost:17817/Default.aspx
if you right click a line in the code, it gives you a conditional breakpoint. Check the name of the variable that has the URL value, and set a condition when typeof URL === 'undefined' or url === 'undefined' and look at the stack
Just set breakproint at line 3400 (with no conditions). It does not go through there.
3397 ajax: function( s ) {
3398 // Extend the settings, but re-extend 's' so that it can be
3399 // checked again later (in the test suite, specifically)
3400 s = jQuery.extend(true, s, jQuery.extend(true, {}, jQuery.ajaxSettings, s));
Narrowed issue down a bit => commented out 1 ascx controller that renders some images and uses gallerific jquery plugin and magic request dissapeared.
Problem was with galleriffic plugin initialization. It couldn't find anchor and it's href for creating thumbnails when there were no images or something. It's cool now...
View 3 Replies
Jul 24, 2010
I am using C# + VSTS 2008 + .Net 3.5 + ASP.Net + IIS 7.0 + ADO.Net + SQL Server 2008. I want to develop an ASP.Net aspx page which has the following function,
1 It could accept 3 Url parameters param1, param2 and param3, and the request looks like this,
http://mysite.com/foo.aspx?parame1=abc¶m2=def¶m3=ghi
2 When the page is responsed to client browser, I want to display a text input and a submit button nearby in the result html page, and value of text input is the same as param1, in this sample, abc will be displayed in text box, in the browser address bar, I want to keep the original long url http://mysite.com/foo.aspx?parame1=abc¶m2=def¶m3=ghi;
3 When the user change the value in text input, and click submit button, I want to send this request again to foo.aspx, and changing the param1 value to the value which user entered in text input, and at the same time, keep values of parame2 and param3 the same as last request's response. For example, when user requests http://mysite.com/foo.aspx?parame1=abc¶m2=def¶m3=ghi, and the page displays, when user changes text input from abc to google, the new request will be http://mysite.com/foo.aspx?parame1=google¶m2=def¶m3=ghi
Any reference samples? My question is I do not know how to implement so many functions in one aspx page.
View 1 Replies
Aug 21, 2010
In how many ways can an HTTP request be generated?
View 2 Replies
Jul 22, 2010
picking up the Users MAC address from the HTTP request.
The users will be from OUTSIDE my network.
View 3 Replies
Feb 21, 2010
I need to I can make the web request to a webservice which take a XML argument. And is expected to return a Binary response. I am able to make the request but while recieving the response back I am unable to get the response in binary. When I read the response
using streamreader see the header and some attached "HEBRISH" words probably binary but unable to sepreate it out. Please help in seprating out the binary the response data.
View 1 Replies
May 10, 2010
how do u handle dates in mvc when request is a http GET? I remember some discussoin on this last year but cant find the posts.. things like culture unaware, splitting the date field to 3 text fields insted of 1.
View 6 Replies
Aug 5, 2010
Is it possible to edit HTTP request using fiddler so that my asp.net application hosted elsewhere return true for the following code block
HttpContext.Current.Request.Url.Host == "localhost"
View 1 Replies
Feb 17, 2011
I am curious to know the reasons why the HTTP request encodes(URLEncoded) all the parameters before sending it across the network in POST request.
View 1 Replies
Mar 3, 2011
I am trying to implement Message API
I am not sure how I will be calling this from code-behind and in their snippet it says:
https://platform.3cinteractive.com/api/send_message.php
POST
username=aRDSe3vcaMzh06YrMcxcQw==&password=1BSvQc6lpNlnp4ufWgRLPHNJ7RMrL8CcaWCzL1Vtw+Y=&phone_number=+11234567890&trigger_id=1105&message=howdy
View 2 Replies