Jquery - Get HttpRequest With A Web Method?

Oct 1, 2010

I have a page web method, and I need to get access to the headers, and particularly the uploaded files. Is this possible? Can a web method receive a file?If not, what would you recommend to upload files without post back? I am using the jQuery forms library that has support for this (and I have had it working with Django), however, I am having a hard time finding answers on how to do this with ASP.NET.

View 2 Replies


Similar Messages:

Unit Testing - Mocking HttpRequest In .NET 4.0 / HttpRequest Is Sealed With No Interface

Jul 15, 2010

I'm writing unit tests in ASP.NET 4.0 web application (ASP.NET Forms, not MVC). There are several spots in the code where I call the ServerVariables collection to call variables like REMOTE_ADDR. Since my unit tests do not actually initiate HttpRequests when executing my code, things like ServerVariables are Null and therefore error when I try to call HttpContext.Current.Request.ServerVariables("REMOTE_ADDR")

All the solutions I've found to address this issue refer to MVC and so they assume that HttpRequest derives from HttpRequestBase, which it does in MVC but not in ASP.NET Forms.I tried using Moq but you can't mock a sealed class, and HttpRequest is unfortunately sealed with no interface.

View 1 Replies

JQuery-AJAX Calling Page Method / How To Return Value Back To JQuery

Jan 31, 2011

If I use jQuery AJAX to call a specific ASP.NET page method how to have that method return a value back to the AJAX method that called it?

Update

My situation is I have an existing web application with many existing methods. I would like to be able to use jQuery to execute some of these methods and then update the UI with the results. My mandate is to stay away from ASP.NET AJAX and stick with jQuery. Management is concerned about continued development and support with ASP.NET AJAX from Microsoft. I agree with them.

View 3 Replies

JQuery :: Data Size While Making Cross Domain JSONP Call Using JQuery .ajax() Method

Dec 21, 2010

I am developing web application and in application i need to make call of jQuery using .ajax(); method with datatype is set jsonp. Now all works well with limited data but problem start to occur when data size is increasing......

View 7 Replies

Jquery And Updatepanel : Binding Jquery Method At A Common Place?

Mar 17, 2011

I am using multiple user control in my web page. Each of these usercontrol has $(document).ready() method. Because i am using an update panel, i am binding all the events again in end_request event. But I dont want to do that in all my usercontrols. Is is possible to do this at a common place(only once)?

View 1 Replies

.NET HttpRequest From 1.1 To 3.5?

Jan 12, 2010

We have to ASP.NET applications, one in 1.1 and one in 3.5. In order to log our errors in the same location we are going to create a WebService that the 1.1 app can call. If I include an HttpRequest as one of the parameters to the webservice, will there be a versioning problem?

View 1 Replies

How To Get Host Name Without Using HttpRequest

Jan 29, 2010

I'm want to run a "background job" in my ASP.NET application (periodically, as separate thread). And I need host name (DNS name or IP) to do my tasks. The problem - HttpContext.Current may be not available here (it's NULL).

Is there any way to get a host name in not using HttpContext.Current.Request.Url.Host.

View 3 Replies

C# - How To Queries Are Sent Back In An HttpRequest

Aug 11, 2010

I'm going to try to use the WebClient object in .NET to grab the response querystring values sent back by the resource.

I'm familiar with grabbing xml, json, etc. but typically I haven't worked with many NVP type of APIs in terms of grabbing the query immediately from an response sent back from a resource server-side. So how is a query sent back, in the body of a response, header, what? How do you grab it, with the stream object just like you do anything else? This questions relates to the environment I work in C# but really it relates to the web as a whole as well which is why I tagged this in multiple categories as a Request/Response is not MS specific however I am also at the same time trying to utilize the .NET WebClient object.

View 1 Replies

Populating HttpRequest.Browser Properties?

Jan 7, 2010

I'm creating HttpContext "by hands" (see [URL]. Does somebody know how can I populate HttpRequest.Browser class's properties (the HttpRequest.Browser.Browser one)? Unfortunately, the HttpBrowserCapabilities class has no the appropriate setter and adding the corresponding http header to the request gives no result.

View 1 Replies

C# - HTTPRequest.Files.Count Never Equals Zero?

Dec 10, 2010

I have a form on an HTML page that a user needs to use to upload a file which posts to an ASPX page. In the code behind, I want to test if a file has actually been loaded.

if (Request.Files.Count > 0)
{
DoStuff(Request.Files[0]);
}
else
{
throw new Exception("A CSV file must be selected for upload.");
}

I am never getting to the else. Is this just how ASP.NET operates? If I have a input element of type file, is it always going to upload a "file" even if one is not selected? What's the proper way to do this? Maybe this?

if (Request.Files.Count > 0 && Request.Files[0].ContentLength > 0)
{
DoStuff(Request.Files[0]);
}
else
{
throw new Exception("A CSV file must be selected for upload.");
}

View 3 Replies

Vb - HttpRequest Maximum Length Exceeded In ASP

May 18, 2010

I'm trying to fix an issue with an application I'm supporting (I didn't write the code). The code takes an SSRS report and renders it in pdf format. Users are sporadically getting the error indicated in the title. There is no rhyme or reason to when the error is generated (a particular report will run one time and throw the error the next). The code is below.

Public Sub OpenReport()
Dim MyParms As New Generic.List(Of ReportParameter)
Dim mimeType As String = Nothing
Dim encoding As String = Nothing
Dim extension As String = Nothing
Dim deviceInfo As String = Nothing
Dim streamids() As String = Nothing
Dim warnings As Microsoft.Reporting.WebForms.Warning() = Nothing
Dim bytes() As Byte
Dim format As String = "PDF" ''#to open the report in pdf; report viewer invisible
Try
If dropReports.SelectedItem.Value = "1" Then
If Session("IsBDAP") = True Then
MyParms.Add(New ReportParameter("SCAId", dropSCA.SelectedItem.Value, False))
Else
MyParms.Add(New ReportParameter("SCAId", Server.UrlEncode(Session("SCAId")), False))
End If
MyParms.Add(New ReportParameter("ProviderId", dropProvider.SelectedItem.Value, False))
If dropVisit.Visible = True Then
MyParms.Add(New ReportParameter("VisitId", dropVisit.SelectedItem.Value, False))
End If
MyParms.Add(New ReportParameter("FY", dropContractFY.SelectedItem.Value, False))
ReportViewer1.ProcessingMode = ProcessingMode.Remote
ReportViewer1.ServerReport.ReportServerUrl = New Uri(System.Configuration.ConfigurationManager.AppSettings("ReportServerURI"))
ReportViewer1.ServerReport.ReportPath = Session("ReportsFolder") & "MReport"
ReportViewer1.ServerReport.ReportServerCredentials = New MyReportServerCredentials()
ReportViewer1.ServerReport.SetParameters(MyParms)
''#Code to convert the report to pdf
deviceInfo = "<DeviceInfo>" + "<SimplePageHeaders>True</SimplePageHeaders>" + "</DeviceInfo>"
bytes = ReportViewer1.ServerReport.Render(format, deviceInfo, mimeType, encoding, extension, streamids, warnings)
Dim size As Integer = bytes.Length
ReportViewer1.ServerReport.Refresh()
Response.Buffer = True
Response.Clear()
Response.ContentType = mimeType
Response.AddHeader("content-disposition", "attachment; filename=MReport." + extension)
Response.BinaryWrite(bytes)
ElseIf dropReports.SelectedItem.Value = "2" Then
If Session("IsBDAP") = True Then
MyParms.Add(New ReportParameter("SCAId", dropSCA.SelectedItem.Value, False))
Else
MyParms.Add(New ReportParameter("SCAId", Server.UrlEncode(Session("SCAId")), False))
End If
MyParms.Add(New ReportParameter("ProviderId", dropProvider.SelectedItem.Value, False))
If dropVisit.Visible = True Then
MyParms.Add(New ReportParameter("FollowUpVisitId", dropVisit.SelectedItem.Value, False))
End If
MyParms.Add(New ReportParameter("FY", dropContractFY.SelectedItem.Value, False))
ReportViewer1.ProcessingMode = ProcessingMode.Remote
ReportViewer1.ServerReport.ReportServerUrl = New Uri(System.Configuration.ConfigurationManager.AppSettings("ReportServerURI"))
ReportViewer1.ServerReport.ReportPath = Session("ReportsFolder") & "FReport"
ReportViewer1.ServerReport.ReportServerCredentials = New MyReportServerCredentials()
ReportViewer1.ServerReport.SetParameters(MyParms)
''#Code to convert the report to pdf
deviceInfo = "<DeviceInfo>" + "<SimplePageHeaders>True</SimplePageHeaders>" + "</DeviceInfo>"
bytes = ReportViewer1.ServerReport.Render(format, deviceInfo, mimeType, encoding, extension, streamids, warnings)
ReportViewer1.ServerReport.Refresh()
Response.Buffer = True
Response.Clear()
Response.ContentType = mimeType
Response.AddHeader("content-disposition", "attachment; filename=FReport." + extension)
Response.BinaryWrite(bytes)

I read that the default length limit is 4MB. None of the reports by themselves are even over 350K. I'm wondering if this could be caused by a caching issue. I'm not an expert, so I need some guidance as to how best to solve the problem. I also want to understand why the issue is happening. note that only 2 reports are shown in the snippet - there are about 30+ reports in the full sub. edit - I tried the proposed solution, but it didn't help (I also tried the Fiddler route, but did not see anything glaring). I thought it might be best to clarify. The reports will run fine for a while, but the execution time gradually gets slower and slower until the application eventually displays the error.

View 3 Replies

Difference Between HttpMethod And RequestType Of HttpRequest?

Jan 28, 2010

The HttpRequest class defines two properties:

HttpMethod:

Gets the HTTP data transfer method (such as GET, POST, or HEAD) used by the client.
public string HttpMethod { get; }
The HTTP data transfer method used by the client.

and RequestType:

Gets or sets the HTTP data transfer method (GET or POST) used by the client. public string RequestType { get; set; } A string representing the HTTP invocation type sent by the client.What is the difference between these two properties? When would i want to use one over the other? Which is the proper one to inspect to see what data transfer method was used by the client?The documentation indicates that HttpMethod will return whatever verb was used: such as GET, POST, or HEAD while the documentation on RequestType seems to indicate only one of two possible values: i test with a random sampling of verbs, and both properties seem to support all verbs, and both return the same values:

Testing:

Client Used HttpMethod RequestType
GET GET GET
POST POST POST
HEAD HEAD HEAD
CONNECT CONNECT CONNECT
MKCOL MKCOL MKCOL
PUT PUT PUT
FOOTEST FOOTEST FOOTEST

What is the difference between:

HttpRequest.HttpMethod
HttpRequest.RequestType

and when should i use one over the other? Keywords: iis asp.net http httprequest httphandler

View 2 Replies

Get The Raw Response Header And Body From The HttpRequest?

Feb 18, 2010

Is there a way to get the raw response header and body from the HttpRequest.Response object for debugging when issues arrise?

View 4 Replies

MVC :: Get The Object Of HTTPRequest - Logon User Details

Aug 17, 2010

Anyway I can get the object of HTTPRequest? From View or Action? What I want is to read the logon user name and its email address from active directory.

View 1 Replies

WCF / ASMX :: How To Capture SOAP Fault With HttpRequest

Jun 3, 2010

I use HttpRequest, when there is a SOAP fault, I get 500 error. I read that you can get the SOAP fault info in the response stream, but when there is a 500 error, how do you get the response stream?

View 1 Replies

Mvc Rhino Mocks Mocking Httprequest Values?

Jul 7, 2010

here Im trying to write a test can I mock a HttpRequestBase to return post values like this? please help as its quite urgent, how can I acheive this?

var collection = new NameValueCollection();
collection.Add("Id", "1");
collection.Add("UserName", "");

[code]...

View 1 Replies

Web Forms :: How To Extract A Portion Of A String That Is Returned From A HTTPRequest

Jan 19, 2010

im writing a whois lookup page for a clients website and the whois query for .com .biz etc is handled by internic,

i create a HTTPRequest and get the response and it returns a whole webpage with the doctype, head tags and body tags, all i want is the data between the tags <pre> and </pre> how would i get just this from the string that is returned?

View 3 Replies

Change Or Remove HttpRequest Input Arguments In HttpModule

Jan 17, 2011

Is it possible to change or remove http request form inputs in an httpmodule? My goal is to create a security IHttpmodule that will check the request for reasonable values, such as limits on acceptable input and query parameter length, or use the AntiXSS Sanitizer to remove threats, log potential hack attempts, etc. before a request is passed on to a processor.

Because this is a cross cutting concern I'd prefer to find a solution that applies to all requests and affects all ways request values could be accessed, Reqest.Form, Action(model), Action(FormCollection), HttpContext.Current.Request.Form, etc. I'm using MVC and have considered creating custom model binders to clean the data before creating the model instance. But that would be application specific, require remembering to register every model binder and only apply to Action(model).

View 1 Replies

JQuery :: Run Method On Key Press?

Mar 10, 2011

I have a calendar with meetings in it, i want to be able to highlight an event on the calendar and then press delete to delete it.

I can handle the clicking the evet and then perhaps store the id of the meeting into a session variable.

is it posible to have a key press in jquery that will fire a method that will delete the event according to the session variable?

View 2 Replies

Php - Jquery Method Is Not Allowed

Sep 15, 2010

How can allow this page to run on IIS server...It does not work on localhost..... it works when I open it directly... It gives the error "it is not allowed...!

The working Example..! I want this.. ""

the Erorr:

<html>
<head>
<script src="jquery.js" type="text/javascript" language="javascript"></script>
<script src="jquery.xml2json.js" type="text/javascript" language="javascript"></script>
<script>
function sayHello(msg)
{
alert(msg);
}
function dcSetRate(obj,value){
document.getElementById(obj).value = value.toFixed(4);
}
function dcSet(obj,value){
document.getElementById(obj).value = value;
}......

View 3 Replies

Can't Call Page Method From JQuery?

Jun 2, 2010

I have a page called AddNews.aspx and in codebehind a web method called AddNews(Parameters).. AddNews.aspx page is inherited from a master page.. So i used contentplaceholder. I have a button..It's id is btnSave.

$(function() {
$("[id$='_btnSave']").click(function() {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
data: $.toJSON(veriler),
url: "AddNews.aspx/AddNews",
dataType: "json",
success: function(result) {
$("#result").html('News added');
},
error: function() {
alert('Problem');
}
});
});
});
</script>

Button click trigger now.. But it doesnt call Web Page Method.. What's the problem?

View 1 Replies

Validating Data Sent To A Web Method From JQuery

Nov 30, 2010

I have been thinking what is the right way to validate the data I am sending to a web method from jQuery ajax call. I have formerly used updatepanels to do my ajax, but am trying to shift to jQuery now and validation seems to get more complicated.

So obviously there are both client- and server-side validation options. At first I tried implementing jQuery validation plugin and got it working. But surely client-side validation is not good enough alone. Then I considered implementing regular asp.net validation to validate on the server. But what if a user tampers the input parameters after the validation happened. He could break the execution of the script in Firebug and change the input to whatever he wanted. So how can I either prevent that or implement validation in the web method?Here is my ajax call which sends a message to the server. [Code]....

You see I am sending three parameters (id of the person who this message is ment for, message type and message text). Even if I implement asp.net validation against input controls, a user might change those input values in Firebug, right? So I need to validate the input again in the web method? Or what would be the best way from the beginning?

View 6 Replies

JQuery :: Retrieving Xml From Page Method

Feb 8, 2011

I use jquery to bind data from web method to jquery grid it does not retieve the data

jQuery("#list2").jqGrid({
url:"NewAprch.aspx/SampleEngagement",
datatype: "xml",

but it works fine when i am trying to use a static variable

var mystr ="<row><cell>abc</cell></row>"

View 1 Replies

MVC :: JQuery Post To An Action Method?

Oct 19, 2010

I'm trying to use the jQuery.post() function to post an object to an action method, but for some reason the nested objects aren't initialised properly when they're received by the action method.

Here's my javascript code:

[Code]....

And my action method:

[Code]....

company.Id has a value of 10, but company.User.Id is 0. what I'm doing wrong? I've not named any properties incorrectly, by the way.

View 1 Replies

JQuery Method Not Working Second Time?

Mar 24, 2011

I have a JQuery Method. When I click on button "btnSelectDisclosure", a popup appears but only once. Not for next time.

[code]...

View 1 Replies







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