VS 2008 - Return XML Response From HTTP Request

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


Similar Messages:

HTTP Response And Request In Binary

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

Sending OK Response Over HTTP To Webpage Request

May 12, 2010

I am using an SMS Gateway to make my application receive SMSs. For this, the SMS Gateway sends a request to one of the pages in my application with the message as a querystring parameter. eg.[URL]. Now after my page gets invoked, I need to send an OK response to the SMS Gateway so that it doesn't keep retrying to send the same message to my application again and again. I cannot figure out how to send the OK response.

View 1 Replies

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

Configuration :: ReadResponse() Failed - The Server Did Not Return A Response For This Request.

Sep 21, 2010

i am experiencing this error when i try to browse one of the application.The same app is working fine in the morning but when i tried to debug the app i am facing the error .Now i removed the debugger but still am facing this error.

View 1 Replies

VS 2008 - View HTTP Request As Text

Sep 13, 2012

Is there a way to view my full HTTP request as text when creating it with WebRequest.Create, after I have added all the headers?

objHttpWebRequest = CType(WebRequest.Create(URL), HttpWebRequest)

View 3 Replies

C# - How To Simulate Http Request Using WatiN With Specific HTTP Referrer And Query String

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

HttpHandlers / Modules :: Redirect A Page From Http To Https Using Http Module Begin Request Handler?

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

WCF / ASMX :: Request Failed With HTTP Status 400: Bad Request Accessing Web Service

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

Determine If A HTTP Request Is A Soap Request On HttpApplication.AuthenticateRequest

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

First Request Fails With HTTP 400 (Bad Request) After Reading HttpRequest.InputStream

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

Accessing IIS's Request Handling Pipeline To Inject A Request And Get The HTML Response?

Dec 9, 2010

Is it at all possible to inject a request into IIS for a page, have IIS and ASP.Net handle it as normal, but get the response as html handed back to me programmatically?

Yes, I know that I could connect to port 80 using WebRequest and WebResponse, but that becomes difficult if you are accessing the IIS server from the same physical machine (loopback security controls et al).

Basically, I want to inject the request (eg for [URL]) between the points at which IIS would normally talk to the browser, and the point at which it would route it to the correct ASP.Net application, and get a response back from IIS between the points at which ASP.Net/IIS applies the httpfilters and hands the html back to the browser.

I'm predominantly working with IIS7 so if there is a solution that works just for IIS7 then thats not an issue.

View 2 Replies

C# - MP3 Download In An HTTP Response?

Jun 9, 2010

I've a question about something I'm searching for,for too long! We've build an application from which an admin upload songs into a database. Then user can bought songs and download it individualy. The problem is that when user download MP3 songs with the code below, it works great in Firefox and Chrome but not in IE8 simply because WMP trying to open the songs and it just don't get it instead of having a "Save as" dialog? Any issue on HOW can i force to have the "Save As" diaglog? Note that I have not MP3 physicaly on server it's in database. So I can't direct link to song ...

Here's my code :

// Remove "specials chars"
foreach (char aChar in @"/:*?""<>| ") {
if (aChar == ' ') {
songNameAndExt = songNameAndExt.Replace(' ', '_');
} else {
songNameAndExt = songNameAndExt.Replace(aChar.ToString(), string.Empty);
}
}
Response.Clear();
Response.ClearHeaders();
Response.ClearContent();
HttpContext.Current.Response.ContentType = "application/octet-stream";
HttpContext.Current.Response.Headers.Add("Content-Disposition", string.Format("filename={0}", songNameAndExt));
HttpContext.Current.Response.OutputStream.Write(songData, 0, songLength);

View 1 Replies

Web Forms :: Get Response Value - From Http Post

Mar 23, 2011

What wrong with this code?

[Code]....

I would like the numeric values of the enum of Response.StatisCode

View 1 Replies

Custom HTTP Response C# And Ajax?

Apr 4, 2011

I'm trying to query a database that contains information about a "ticket" using jQuery's .ajax() method.

$.ajax({
type: 'GET',
url: 'Preview.ashx',
data: 'ticketID=' + ticketID,
success: function (data) {
// 'data' should be a row from the database, so it should be like an
// array that contains each column of the row
// do stuff with this data
}
});
... so that all works fine. I'm having trouble with the data variable. On the server side, I do...
// get the ticket ID from the POST parameter
int ticketID = context.Request["ticketID"] != null ? Convert.ToInt32(context.Request["ticketID"]) : -1;
if (ticketID >= 0) {
// grab the data from the database, getInfo() will retrieve the row
// in the DB that corresponds to the ticket ID given, returning an
// ArrayList with all of the information
ArrayList theTicket = getInfo(context, ticketID);
// now, I need to somehow return this information so that I could deal with it
// in the 'success' callback function above
return;
} else {
// something went wrong with the 'newTicket' POST parameter
context.Response.ContentType = "text/plain";
context.Response.Write("Error with 'ticketID' POST parameter.
");
return;
}
return;

I've debugged this enough to be sure that the ArrayList contains the correct information. Now I just need to return it. How would I do this? How would I return the data in the ArrayList? Is it possible to structure the response so that I could do data.ID, data.otherColumnName, etc... in the callback function to access the different fields?

View 3 Replies

Suppressing HTTP 500 Response Codes

Feb 10, 2010

I've had a bit of feedback from some threat and vulnerability folks relating to websites returning HTTP 500 response codes. Essentially the advice is that all possible measures must be taken to avoid the server throwing a 500 (i.e. extensive form input validation) which is fine. However, the advice also suggested that attempts to compromise security by means such as inserting a tag into a random query string causing ASP.NET request validation to fire or manipulating viewstate also should not return an HTTP 500. Obviously the native framework behaviour is to interpret the request and possibly throw to a custom error page but even this will return a 500 response code.

So I'm after some thoughts on how to approach this. Is there any way to configure the app at either the .NET level or IIS level to return an HTTP 200 when a 500 is raised? Or does this become a coding exercise at global.asax level in one of the application events? Are there other consequences to consider? BTW, the rationale from the security side is that apps which return HTTP 500 may be viewed as "low hanging fruit" by bots randomly scanning for vulnerabilities and prompt further malicious activity. attempts I'm personally not convinced that changing response codes offers any real security gains but am happy to hapy to take the advice of the pros.

View 3 Replies

Response - Get Custom Http Header?

May 14, 2010

I have an asp.net appliction on the one server. There I've added code on server-side in Page_Load:

Response.AddHeader("key", "password-key-from-hotel");

On the client side I have a form:
<form ... action="www.link-to-another-domaint" >
<input type="hidden" id="asd" value="fgh" >
....
</form>
<script type="text/javascript">
document.forms[0].submit();
</script>

Then on the other domain - there is also my other application - I'm trying to get the hedaer "key" by this code:

Request.Headers["key"].ToString();

But there is no such header. Is there is a desicion? Where is my mistake?

View 2 Replies

Add Response Http Headers In Web Configuration?

May 27, 2010

In my application I need to set a http response header. I'd like to do this in web.config. but I dont'know if this is possible and I can't find it on Google. Solution Finally, after a long search I found the solution. Create a class with this code:

public class myHTTPHeaderModule : IHttpModule
{
#region IHttpModule Members
public void Dispose()
{
}
public void Init(HttpApplication context)
{
context.EndRequest += new EventHandler(context_EndRequest);
}
void context_EndRequest(object sender, EventArgs e)
{
HttpResponse response = HttpContext.Current.Response;
response.AddHeader("Content-Language", "*");
}
#endregion
}

(Don't ask me why to use this event, but it works..) Now add a line in web.config in the HttpModule section:

<httpModules>
<add type="namespace.myHTTPHeaderModule, assembly name" name="headers" />
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</httpModules>

View 4 Replies

C# - Exactly Does Response.Redirect("~/...") Put In The HTTP Response?

Nov 24, 2010

I've just finished reading URL vs. URI vs. URN, in More Concise Terms, and it's really helped understand the distinction between the three terms. Since then I've skimmed the RFC2141 and RFC2616 specs and Microsoft's Response.Redirect Method documentation in an effort to answer the following question confidently.

Given this line of code:

Response.Redirect("~/Foo.aspx");

And this resulting HTTP response (trimmed for context):

Status=Found - 302 Date=Wed, 24 Nov
2010 17:27:58 GMT
Server=Microsoft-IIS/6.0
X-Powered-By=ASP.NET
X-AspNet-Version=2.0.50727
Location=/MyWebApp/Foo.aspx

What name(s) most properly describes what has been placed into the "Location" header?

URL? URI? URN? URC? Which is it?

View 5 Replies

How To Hunt Down HTTP Request

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

C# - Http Request Issue In Asp.Net

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

Generating HTTP Request?

Aug 21, 2010

In how many ways can an HTTP request be generated?

View 2 Replies

Get MAC Address From HTTP Request

Jul 22, 2010

picking up the Users MAC address from the HTTP request.

The users will be from OUTSIDE my network.

View 3 Replies

Creating Dynamic Http Response From Component

May 14, 2010

I've developed a component which processes online payments. At a specific point the user must be redirected to the selected acquirer web site for authentication. The acquirer itself suggests that there should be a web page which does it. Something such as the following,

<!--TakeOff.aspx-->
<html xmlns="[URL]">
<head id="Head1" runat="server">
<title>@</title>
<script type="text/javascript">
function Go() {
form1.submit();
}
</script>
</head>
<body onload="Go();">
<form id="form1" runat="server" method="post" action="/...">
<div>
<asp:HiddenField ID="MID" runat="server" />
<asp:HiddenField ID="Amount" runat="server" />
<asp:HiddenField ID="ResNum" runat="server" />
<asp:HiddenField ID="RedirectURL" runat="server" />
</div>
</form>
</body>
</html>

This page redirects the user and posts required arguments to the acquirer's web site. Prior to this page there is another page with a payment button (for example). In the click event of the payment button my component is instantiated and required calculation is done. Something such as the following,

protected void btnPayment_Click(object sender, EventArgs e)
{
try
{
var paymentProcessor = new NS.PaymentProcessor(/*required arguments*/);
/*...*/
NS.Result result = paymentProcessor.Calc();
Session.Add("PaymentProcessResult", result);
Response.Redirect("TakeOff.aspx");
}
catch (Exception p)
{
throw p;
}
}

What I'm going to do is to generate [TakeOff.aspx] page at run-time by the payment processor component instead of having static page (I mean aspx pages that are generated during development phase). The reason why is that we may have different acquirers and each acquirer requires its own arguments to be posted. So if the payment processor component generates aspx or even html pages at run-time we do not need recompile and redeploy the web application.

My problem is that I do not know how to generate aspx pages at run-time. I'm not an ASP.NET guru and all efforts that I've made using HttpResponse were in vain as the original page does not transfer the control to the generated page.

View 1 Replies

HTTP Response Behavior - Cause Browser To Prompt

Jan 5, 2011

I have two very similar pieces of ASP.NET code that send a file in an HTTP Reponse to the client. They should cause the browser to prompt to save the file. The first one works, the second one doesn't. The HTTP responses as seen in Fiddler are below.

Working:
HTTP/1.1 200 OK
Cache-Control: private
Content-Length: 228108
Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 4.0.30319
content-disposition: attachment; filename=Report.xlsx
Date: Wed, 05 Jan 2011 12:17:48 GMT
<binary data>

Not working:
HTTP/1.1 200 OK
Server: ASP.NET Development Server/10.0.0.0
Date: Wed, 05 Jan 2011 12:19:21 GMT
X-AspNet-Version: 4.0.30319
Content-Length: 228080
content-disposition: attachment; filename=report 2.xlsx
Cache-Control: private
Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
Connection: Close
<binary data>

When the first one is seen in Fiddler the browser correctly prompts to save the file. When the second one is seen in Fiddler, nothing observable happens in the browser. Same behaviour in both chrome and firefox.

EDIT: ASP.NET code that produces the second response

Response.Buffer = false;
Response.ContentType = @"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
Response.AppendHeader("content-length", genstream.Length.ToString());
Response.AppendHeader("Content-Disposition", string.Format("attachment; filename={0}.xlsx", filename));
byte[] buffer = new byte[1024];
genstream.Position = 0;
int n;
while ((n = genstream.Read(buffer, 0, 1024) ) > 0)
{
Response.OutputStream.Write(buffer, 0, n);
}

View 4 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved