webmethod

Getting “401 Unauthorized” error consistently with jquery call to webmethod

谁说胖子不能爱 提交于 2019-12-01 01:14:28
问题 I have been struggling to get my jquery call to a webmethod to work. I am being bounced by the server with a "401 Unauthorized" response. I must have an incorrect setting in the web.config or somewhere else that would be preventing a successful call. Your insight is appreciated! Call to js function the invokes the jquery call button.OnClickAction = "PageMethod('TestWithParams', ['a', 'value', 'b', 2], 'AjaxSucceeded', 'AjaxFailed'); return false;"; JavaScript function that makes the jquery

Timeout using ServiceStack.Client

你。 提交于 2019-12-01 00:04:30
I have been using service stack via AJAX calls for some time without issue, but have recently created a quick winforms app which utilizes the service stack client (specifically JsonServiceClient). However - I have hit a problem whereby I consistently get a timeout on a call which works successfully on the the first TWO attempts. It looks like either the service stack client is holding on to some resource, or I am using the client in the wrong way. It only occurs when running against a remote service (works every time on a local machine). Here is my code, and the exception: var url = "http:/

$.ajax Returning HTML of the page instead of results

旧城冷巷雨未停 提交于 2019-11-30 20:39:50
I wrote a simple webmethod that I call on the client side to check if a value exists in the database on text change. It works fine locally, but when I move it to our Development environment it returns the entire HTML of the page in the response. The only thing that I have noticed is that locally the Response.Server is IIS7.5, but on our Dev server it is IIS6. Here is my code: Server Code [ScriptMethod] [System.Web.Services.WebMethod] public static bool CheckInvoiceExists(string vendorNumber, string invoiceNumber) { try { return RequestEntry.CheckInvoiceExists(vendorNumber, invoiceNumber); }

using web methods with master pages

…衆ロ難τιáo~ 提交于 2019-11-30 19:48:11
I've got a function on all pages in my site which is located in my master page and I want it to run from some jQuery Ajax method. I've got some code like this at the moment jQuery $(document).ready(function() { $("#test").click(function() { $.ajax({ type: "POST", url: "Default.aspx/GetDate", data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", success: function(msg) { $("#test").text(msg.d); } }); }); }); HTML in Master page <div id="test">Click here for the time.</div> Asp.Net code behind in my Master VB <WebMethod> _ Public Shared Function GetDate() As String Return

Timeout using ServiceStack.Client

十年热恋 提交于 2019-11-30 18:06:31
问题 I have been using service stack via AJAX calls for some time without issue, but have recently created a quick winforms app which utilizes the service stack client (specifically JsonServiceClient). However - I have hit a problem whereby I consistently get a timeout on a call which works successfully on the the first TWO attempts. It looks like either the service stack client is holding on to some resource, or I am using the client in the wrong way. It only occurs when running against a remote

How can i call [WebMethod] which is defined in user control?

﹥>﹥吖頭↗ 提交于 2019-11-30 16:01:58
I am working in Asp.Net using C# and I have a [WebMethod] defined in a User Control. I don't want to use a web service. How can I call a method with an [WebMethod] attribute? I want to call it from a jQuery (Ajax) request. You cannot call a page method declared within an ASCX user control. The page method would have to be declared in your aspx or expose it as a proper asmx web service. You really should reconsider using a service if your goal is to centralize shared functionality. ASMX services don't have any of the configuration burden that WCF services do (which is often what comes to mind

How to download file via jquery ajax and C#

我怕爱的太早我们不能终老 提交于 2019-11-30 08:22:39
问题 I want to download a file using jQuery Ajax web method, but it's not working. Here is my jQuery ajax call to web method: function GenerateExcel() { var ResultTable = jQuery('<div/>').append(jQuery('<table/>').append($('.hDivBox').find('thead').clone()).append($('.bDiv').find('tbody').clone())); var list = [$(ResultTable).html()]; var jsonText = JSON.stringify({ list: list }); $.ajax({ type: "POST", url: "GenerateMatrix.aspx/GenerateExcel", data: jsonText, contentType: "application/json;

jQuery Ajax results in undefined

我怕爱的太早我们不能终老 提交于 2019-11-30 07:42:58
问题 I have a simple function which only returns a translated message from the server to the client. But the result shows undefined, when I pass the result into a var. function MessageNoResult() { $.ajax( { type: "POST", async: true, url: '<%= ResolveUrl("~/WebMethods.aspx/MessageNoResult") %>', contentType: "application/json; charset=utf-8", dataType: "json", success: function(msg) { return msg.d; } }); } Result --> Undefined (bad) var message = MessageNoResult(); alert(message); When I look into

How can i call [WebMethod] which is defined in user control?

╄→尐↘猪︶ㄣ 提交于 2019-11-29 23:01:53
问题 I am working in Asp.Net using C# and I have a [WebMethod] defined in a User Control. I don't want to use a web service. How can I call a method with an [WebMethod] attribute? I want to call it from a jQuery (Ajax) request. 回答1: You cannot call a page method declared within an ASCX user control. The page method would have to be declared in your aspx or expose it as a proper asmx web service. 回答2: You really should reconsider using a service if your goal is to centralize shared functionality.

How to format JSON for asp.net webmethod that takes class parameter

时光毁灭记忆、已成空白 提交于 2019-11-29 15:53:09
I have the following webmethod on my asp.net code behind page: [WebMethod(EnableSession = true)] public static bool SaveFailureData(SimpleFailureData data) { } SimpleFailureData is defined as the following: public class SimpleFailureData { public int Id { get; set; } public string Comments { get; set; } public double Score { get; set; } public double Adjustment { get; set; } public List<ShutdownData> ShutdownData { get; set; } } public class ShutdownData { public int Id { get; set; } public string Description { get; set; } public bool CausedShutdown { get; set; } public string ShutdownType {