webmethod

jquery ajax call fails with 401 unauthorized

情到浓时终转凉″ 提交于 2019-12-25 03:53:53
问题 I have a jquery ajax POST to a code-behind webmethod. In that webmethod i do a HttpWebRequest to a third party web api service that returns json. Even though the httpwebrequest works fine, a popup appears in the browser asking me to enter credentials (authentication required). On my machine this works well, however when deployed it doesn't except if there is no data returned from the httpwebrequest call. The jquery call: function serverCall(httpMethod, pageName, methodName, inputData,

Accessing a common variable in WebMethod and jQuery

有些话、适合烂在心里 提交于 2019-12-24 10:46:27
问题 In my ASP.Net page, I am loading data from server while scrolling using jQuery AJAX. I am using this method since loading data from the server using AJAX will help any application in improving its performance because data which is displayed on the screen alone is loaded the first time and more data, if required, will get loaded from the server as the user scrolls. I am using the following code: $(document).ready( function () { $contentLoadTriggered = false; $(window).scroll( function () { if

.NET WebMethod FileUpload

帅比萌擦擦* 提交于 2019-12-24 06:52:00
问题 is possible to upload a file by using FileUpload Control and WebMethod? I would like to avoid the UpdatePanel and ScriptManagers. How can I do it? What kind of parameter the Web Method would be? Is there any example? Thanks! 回答1: I could not find solution you asked using WebMethod so I come up with alternative solution which is using HTTPHandler or better known as ASPX control/page. To achieve what you wanted, I use Valums File Upload , there are many alternative out there but this is the one

Cannot retrieve a querystring parameter.

人盡茶涼 提交于 2019-12-24 00:50:12
问题 An example of the Request URL: http:\\localhost\ChatWindow.aspx?username=sly_chandan My webmethod is listed below: [WebMethod(EnableSession = true)] public static List<PrivateMessage> GetMessages() { List<PrivateMessage> getMsgsList = (List<PrivateMessage>)HttpContext.Current.Application["PrivateMessages"]; var msgs = getMsgsList.Where(x => x.fromUsername == HttpContext.Current.Session["Username"].ToString() && x.toUsername == HttpContext.Current.Request.QueryString["username"]); return msgs

How do you send and receive JSON with jQuery.dataTables 1.10 to a ASP.NET WebMethod backend?

大城市里の小女人 提交于 2019-12-23 20:37:38
问题 Version 1.10 of jQuery DataTables changes a ton of things from the previous versions of DataTables, including how it handles the Ajax requests and responses. The developers of the library do not have any experience working with an ASP.NET backend, so although some of the nuances of WebMethods have been brought up to them in the past, they apparently didn't consider them in this version. For example, the dataSrc DataTables option should be where we deal with the fact that ASP.NET WebMethods

How to return error from webmethod?

走远了吗. 提交于 2019-12-23 12:16:10
问题 How does one return an error in an aspx page method decorated with WebMethod ? Sample Code $.ajax({ type: "POST", url: "./Default.aspx/GetData", data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", success: AjaxSucceeded, error: AjaxFailed }); [WebMethod] public static string GetData() { } How does one return error from a webmethod? So one can be able to use the jquery error portion to show the error detail. 回答1: I don't know if there's a more WebMethod -specific way

LoadControl, usercontrol in WebMethod

狂风中的少年 提交于 2019-12-23 09:33:19
问题 I am trying to send an email through a WebMethod Below is the code I typically use on a regular post back [WebMethod] public static void SendEmail(string name, string phone, string emailaddress, string interest, string comments) { var control = LoadControl("~/Shared/Controls/EmailTemplate_PartnerWithUs.ascx"); StringBuilder sb = new StringBuilder(); StringWriter sw = new StringWriter(sb); Html32TextWriter htw = new Html32TextWriter(sw); control.RenderControl(htw); sb.Replace("%name%", name);

Call a web method using jQuery Ajax

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-23 04:39:06
问题 I want to create an Autocomplete field for a search option. I have tried with following code. But the web method doesn't fire when the Autocomplete function is execution. What will be the reason ? Here is the jQuery function: <script type="text/javascript"> $(function () { $("#<%=tags.ClientID %>").autocomplete({ source:function (request, response) { $.ajax ({ type: "POST", contentType: "application/json; charset=utf-8", url: "~/Services/AutoComplete.asmx/GetFarmersByName", data: "{ 'name' :

Webservice method to call a url

百般思念 提交于 2019-12-23 00:26:27
问题 I have a webservice, it has its wsdl and everything works fine when I make a call to my web service. What I want to do now is call a url from somewhere within my web service method. In c# code behind I can do it something like this: Response.Redirect("Insurance.aspx?fileno1=" + txtFileNo1.Text + "&fileno2=" + txtFileNo2.Text + "&docid=" + Convert.ToString(GridView1.SelectedDataKey[2])); but the Response.Redirect option is not available on the asmx page. Is something like this possible? If so

Export a data set to Excel and raise a file download dialog from an asp.net web method

与世无争的帅哥 提交于 2019-12-22 15:53:08
问题 I am using the following code to export a data set to an Excel sheet. [WebMethod] public static void ExporttoExcel() { DataSet ds; productfactory pf=new productfactory(); ds = pf.getproducts(); HttpResponse response = HttpContext.Current.Response; // first let's clean up the response.object response.Clear(); response.Charset = ""; response.ContentEncoding = System.Text.Encoding.Default; // set the response mime type for excel response.ContentType = "application/vnd.ms-excel"; response