Request.RawUrl Versus Request.Url
Jan 7, 2010What is the difference between Request.RawUrl and Request.Url in ASP.NET?
View 3 RepliesWhat is the difference between Request.RawUrl and Request.Url in ASP.NET?
View 3 RepliesProbably one of those things you know and use every day without thinking what it is:
Do you think Component based frameworks are better than Action/Request based web frameworks?
From the naming I think I'm using both (of course, I must be wrong if things are asked like this).
My web front-end (Pages and Code behind / Views and Controllers) are Request/Action while my other layers are Component based...no?
Or does this apply to specific frameworks or ways doing things?
What are the differences (behind the scenes) between Page.User.Identity and Request.LogonUserIdentity? Not the differences in type, name, etc but the differences in how they're implemented behind the scenes (i.e. one calls windows xxx api and the other calls asp.net xxx api...).
View 1 RepliesWe're trying to implement functionality that intercepts, inspects, and alters if needed data in the Request.QueryString and Request.Form collections.
Since Request.QueryString and Request.Form are readonly, is it possible to use a HttpModule to do this without Reflection or Response.Redirect?
We're thinking that we can construct a new HttpRequest, and replace the original one. Would there be any implications in doing this?
I know mocking this object is impossible without using HttpRequestWrapper, but wasn't sure whether ASP.NET sets other things beyond the constructor.
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 RepliesIs 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.
This is a input
<input type="image" src="<%=Url.Content("~/images/shopping-cart.jpg")%>" alt="shopping cart" id="btnshoppingCart" name="btnshoppingCart" value="shoppingCart" />
when i browse the page with firefox and click on the input Request.Params["btnshoppingCart"] != null or Request.Form["btnshoppingCart"] != null is statisfied.
When i browse the same page with internet explorer 8 and click on the same input Request.Params["btnshoppingCart"] != null or Request.Form["btnshoppingCart"] != null is not satisfied. When i used the watch i saw that there is no key by the name of "btnshoppingCart" in either Request.Form or Request.Params if input is clicked from internet explorer. However when it is clicked from firefox there is value "shoppingCart" inside Request.Form and Request.Params against "btnshoppingCart" key. One more strange thing that i observed was that are two keys "btnshoppingCart.x" and "btnshoppingCart.y" inside both Request.Form and Request.Params whenver clicking is done from both internet explorer and firefox. This is happening against all inputs of type image irrespective if the input is present inside a html form or not. Forms are created like this
<% using (Html.BeginForm("Action", "Controller", FormMethod.Post)){%>
The version of internet explorer is 8.0 and firefox is 3.6.6
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).
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();
I want to component to upload large filesP.How can I bypass request size и request processing time restrictions?
View 4 RepliesI am trying to use curl to access 3rd party webservice, I used the following code which works well if I try it on my own linux server, the data is being sent ok, but the IIS on the 3rd party server returns an error.
$longdata is a long string of data, maybe over 1000 characters long the 3rd party has many working clients with various implementations so the problem is on my side. what do I need to add to the request in order to get this through ?
<?php
$c = curl_init();
// curl_setopt($c, CURLOPT_HTTPHEADER, array('Expect:'));
curl_setopt($c, CURLOPT_URL, 'http://XXX.com/test/index.asmx');
curl_setopt($c, CURLOPT_POST, 1);
curl_setopt($c, CURLOPT_HEADER, 1);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
$post = array('param1' => 'XXXX', "param2" => "Y", "Param3" => $long_data);
curl_setopt($c, CURLOPT_POSTFIELDS, $post);
$response = curl_exec($c);
echo $response;
/*
Response:
HTTP/1.1 100 Continue
HTTP/1.1 500 Internal Server Error
Date: Tue, 05 Apr 2011 14:11:51 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Cache-Control: private
Content-Type: text/plain; charset=utf-8
Content-Length: 100
Request format is invalid: multipart/form-data; boundary=----------------------------5d738237d9e0.
*/
?>
I am facing an issue while calling a web request thru my code. I have searched a lot on number of sites but did not get any solution.
Here is the code which I am using:
[Code]....
What is the difference between the three ASP.NET objects:
HttpContext.Current.Request
HttpContext.Request
Request
Are these exactly the same?
Edit 1
Do these objects behave differently inside global.asax/global.asax.vb and default.aspx/default.aspx.vb.
Edit 2
OK I'll try to be specific this time. Which of the following should I use:
' File: global.asax
Protected Sub Application_BeginRequest(ByVal sender As Object, ByVal e As System.EventArgs)
If Request.Url.Port = 80 Then
'If HttpContext.Current.Request.Url.Port = 80 Then
[Code]...
How do I call Page.Request properties from a thread after the host headers are gone.
I used:
[Code]....
in Page_Load, but still get the error.
My ASP.NET Web app has a thread which calls a method in the Page. This method then calls:
searchQuery = Page.Request.Path
This throws an exception with a message of, "Request is not available in this context."
Encrypt request.querystring and Descrpt request.querystring
View 1 RepliesWebApp1: on IIS and configured with Windows authentication. Get User account from AD.
WebAPP2: a java web app on another windows box in same domain with authentication from AD
On web app1, I have a http handler like
public class MyHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
string url = "http://WebApp2/Test";
HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(url);
CredentialCache myCache = new CredentialCache();
NetworkCredential netCredential = new NetworkCredential("myname", "mypassword", "");
myCache.Add(new Uri(url), "Basic", netCredential);
//...
myReq.Credentials = myCache;
//....
}
}
in above way, I can set authentication in code and pass it WebApp2.
But I don't want to put name and password in code. User info already available on WebApp1: in context.User I can find out the user info who already logined into WebApp1, so I want to pass this credential to WebApp2. I have tried to do following:
myReq.Credentials = CredentialCache.DefaultCredentials;
but I am failed becuast there is no data in CredentialCache.DefaultCredentials.
Both returns the incoming url, Just to know When to use Request.UrlReferrer and when Request.ServerVariables["HTTP_REFERER"] and why?Currently, in one of my application Urlreferrer is working in my local machine but its not working when went live?Additionally, its most appreciable if anyone can guide any alternative of both Urlreferrer and HTTP_REFERRER?
View 1 RepliesI have created a VB DLL by selecting File - New - Project and then Class Library
I added a "Properties" region and a "Function" region with some simple properties and one simple function. Compiled it and used it in another app with no errors.
At that point the only references in the project were the default references when creating the new project.
I then created a function that will take a file as a param and get the physical path and add the 2 together. In the function I use the "Request.PhysicalPath" method of the System.Web.UI.UserControl.
I then added areference to the System.Web DLL in my project.
PROBLEM IS I get an error on "Request" that says "Name Request is not declared"
So I googled the error which I found a thread that said to "just use HttpContext.Current.Request.Form" because "by default all websites developed in Visual Studio 2005 is Inherited from System.Web.UI.Page and Class files won't that's the resion we have to add System.Web.UI.Page namespace in the class file"
However when I added the "HttpContext.Current.form." before my "Request.PhysicalPath" I get the same error on "HttpContext".
System.Web.UI.UserControl
I am trying to add Failed Request Tracing to my IIS 7/ASP.NET server.
First, I create failed request tracing for "all content, error codes 400-999" because want to save all errors.
Then, I try to create a trace for "all content, time: 5 seconds" because I want to trace all "long" requests. However, IIS 7 gives me an error: "A failed request trace for this content already exists".How can I add this second trace for all content that takes > 5 seconds?
I'm using HttpModule to capture requests to the web server. Before processing the page I'd like to check the values contained in some keys of the Request.Form collection and according to some logic change if necessary. I'd like to do this when BeginRequest event is fired. The problem is that the Request.Form collection is readonly.
View 4 RepliesMy Request.Form keys are all prefixed with ctl00$container name$ and then the key I want.
How can I get the regular key name working?
Visual example from the immediate window:
I want to use:
? request.Form.Item("stationIdea")
but it won't work because the key is:
ctl00$content_innovation_body$stationIdea
as retrieved by
? request.Form.Keys("4")
so only this works:
? request.Form("ctl00$content_innovation_body$stationIdea")
We're trying to create a .NET aspx page that will have a PDF within it. Doing this by hardcoding it is easy.
<object height="1250px" width="100%" type="application/pdf" data="our.pdf">
<param value="our.pdf" name="src" />
<param value="transparent" name="wmode" />
</object>
(don't worry too much about the transparent thing...we're doing that for other reasons...but I include it here "just in case".)The problem is when we want to generate the PDF dynamically. Our code to populate the literal on the front end looks like this:
ltrPDF.Text = String.Format("<object height="1250px" width="100%" type="application/pdf" data="ourPdfGenerator.aspx?var0={0}&var1={1}&var2={2}">", var0, var1, var2);
ltrPDF.Text += String.Format("<param value="ourPdfGenerator.aspx?var0={0}&var1={1}&var2={2}">", var0, var1, var2);
ltrPDF.Text += "<param value="transparent" name="wmode"/>";
ltrPDF.Text += "</object>";
Kind of ugly, but it seems like it should work. But it doesn't.When I debug, and put a breakpoint on the first line of ourPdfGenerator.aspx.cs Page_Load method, I reach the breakpoint without any difficulty. However, the first thing we do is try to use Request.QueryString:
string var0 = Request.QueryString["var0"];
which immediately throws an HttpException: "Request is not available in this context." I'm not clear on:
Why isn't it available? What can I do about it?
EDIT: (as an aside, I know it seems a bit weird to ask for a mime-type of pdf from a aspx page...but we've used an aspx page to generate cs pages before...we do something like this:
Response.Clear();
Response.ContentType = "application/pdf";
Response.AddHeader("Content-Disposition", "attachment;filename="our.pdf"");[code].....
And this has been working fine in other contexts for a while...but always as its own page. What we're doing differently now is instead of having this page called directly, we're trying to embed it, so it's being called from the <object> tag, which is apparently causing problems...
How can I get time of last request Sent in asp.net.. Actually I want to set automatic Idle timeout. So I planned to compare this time with current.
View 4 RepliesI'm submitting a request to a web service, but I'm receiving some errors. They've asked to see an example of the xml request and response. I used Visual Studio to consume the web service, so I'm just calling a method in my code - I don't actually see any xml. Is there a way to grab the XML request and response as XML or at least a text string?
View 2 RepliesI need to edit URL like this below www.abc.com/Search?key=xxx I want to pass new variable and request it from URL.
View 10 Replies