Search Results

Search found 295 results on 12 pages for 'webmethod'.

Page 1/12 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • ASP .NET: Cannot call Page WebMethod using jQuery

    - by John
    I created a WebMethod in the code-behind file of my page as such: [System.Web.Services.WebMethod()] public static string Test() { return "TEST"; } I created the following HTML page to test it out: <html> <head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"/></script> <script type="text/javascript"> function test() { $.ajax({ type: "POST", url: "http://localhost/TestApp/TestPage.aspx/Test", data: "{}", contentType: "application/json; charset=utf-8", dataType: "text", success: function(msg) { alert(msg.d); } }); } </script> </head> <body> <button onclick="test();">Click Me</button> </body> </html> When I click the button, the AJAX fires off, but nothing is returned. When I debug my code, the method Test() doesn't even get called. Any ideas?

    Read the article

  • Accessing NHibernate Repository using ASP.NET Ajax WebMethod

    - by LooDaFunk
    Hi there! on my page I have a save button that gets the values from the form and then saves it in the database using NHibernate. This works using ASP.net postback buttons. I have now added an Ajax WebMethod to make things sleek and quicker. Howver, when trying to access the data in the repository it doesn't seem to get it. I am passing in the correct values, and everything looks the same as when you are using the postback but no Joy! I should point out here that I'm a newbie with NHibernate and I'm working with someone elses code. Here's the code: the main problem is this line: Solution.Entities.Hierarchy.Tag tag = tagRep.Get(tagId); The tagID is fine, but when it does the get no exception is raised it just comes out the method and goes back to the page???? http://pastebin.com/cBTp9pnC Anyone have any ideas? Merry Christmas!

    Read the article

  • jqgrid with asp.net webmethod and json working with sorting, paging, searching and LINQ

    - by aimlessWonderer
    THIS WORKS! Most topics covering jqgrid and asp.net seem to relate to just receiving JSON, or working in the MVC framework, or utilizing other handlers or web services... but not many dealt with actually passing parameters back to an actual webmethod in the codebehind. Furthermore, scarce are the examples that contain successful implementation the AJAX paging, sorting, or searching along with LINQ to SQL for asp.net jqGrid. Below is a working example that may help others who need help to pass parameters to jqGrid in order to have correct paging, sorting, filtering.. it uses pieces from here and there... ================================================== First, THE JAVASCRIPT <script type="text/javascript"> $(document).ready(function() { var grid = $("#list"); $("#list").jqGrid({ // setup custom parameter names to pass to server prmNames: { search: "isSearch", nd: null, rows: "numRows", page: "page", sort: "sortField", order: "sortOrder" }, // add by default to avoid webmethod parameter conflicts postData: { searchString: '', searchField: '', searchOper: '' }, // setup ajax call to webmethod datatype: function(postdata) { mtype: "GET", $.ajax({ url: 'PageName.aspx/getGridData', type: "POST", contentType: "application/json; charset=utf-8", data: JSON.stringify(postdata), dataType: "json", success: function(data, st) { if (st == "success") { var grid = jQuery("#list")[0]; grid.addJSONData(JSON.parse(data.d)); } }, error: function() { alert("Error with AJAX callback"); } }); }, // this is what jqGrid is looking for in json callback jsonReader: { root: "rows", page: "page", total: "totalpages", records: "totalrecords", cell: "cell", id: "id", //index of the column with the PK in it userdata: "userdata", repeatitems: true }, colNames: ['Id', 'First Name', 'Last Name'], colModel: [ { name: 'id', index: 'id', width: 55, search: false }, { name: 'fname', index: 'fname', width: 200, searchoptions: { sopt: ['eq', 'ne', 'cn']} }, { name: 'lname', index: 'lname', width: 200, searchoptions: { sopt: ['eq', 'ne', 'cn']} } ], rowNum: 10, rowList: [10, 20, 30], pager: jQuery("#pager"), sortname: "fname", sortorder: "asc", viewrecords: true, caption: "Grid Title Here" }).jqGrid('navGrid', '#pager', { edit: false, add: false, del: false }, {}, // default settings for edit {}, // add {}, // delete { closeOnEscape: true, closeAfterSearch: true}, //search {} ) }); </script> ================================================== Second, THE C# WEBMETHOD [WebMethod] public static string getGridData(int? numRows, int? page, string sortField, string sortOrder, bool isSearch, string searchField, string searchString, string searchOper) { string result = null; MyDataContext db = null; try { //--- retrieve the data db = new MyDataContext("my connection string path"); var query = from u in db.TBL_USERs select u; //--- determine if this is a search filter if (isSearch) { searchOper = getOperator(searchOper); // need to associate correct operator to value sent from jqGrid string whereClause = String.Format("{0} {1} {2}", searchField, searchOper, "@" + searchField); //--- associate value to field parameter Dictionary<string, object> param = new Dictionary<string, object>(); param.Add("@" + searchField, searchString); query = query.Where(whereClause, new object[1] { param }); } //--- setup calculations int pageIndex = page ?? 1; //--- current page int pageSize = numRows ?? 10; //--- number of rows to show per page int totalRecords = query.Count(); //--- number of total items from query int totalPages = (int)Math.Ceiling((decimal)totalRecords / (decimal)pageSize); //--- number of pages //--- filter dataset for paging and sorting IQueryable<TBL_USER> orderedRecords = query.OrderBy(sortfield); IEnumerable<TBL_USER> sortedRecords = orderedRecords.ToList(); if (sortorder == "desc") sortedRecords= sortedRecords.Reverse(); sortedRecords= sortedRecords .Skip((pageIndex - 1) * pageSize) //--- page the data .Take(pageSize); //--- format json var jsonData = new { totalpages = totalPages, //--- number of pages page = pageIndex, //--- current page totalrecords = totalRecords, //--- total items rows = ( from row in sortedRecords select new { i = row.USER_ID, cell = new string[] { row.USER_ID.ToString(), row.FNAME.ToString(), row.LNAME } } ).ToArray() }; result = Newtonsoft.Json.JsonConvert.SerializeObject(jsonData); } catch (Exception ex) { Debug.WriteLine(ex); } finally { if (db != null) db.Dispose(); } return result; } ================================================== Third, NECESSITIES In order to have dynamic OrderBy clauses in the LINQ, I had to pull in a class to my AppCode folder called 'Dynamic.cs'. You can retrieve the file from downloading here. You will find the file in the "DynamicQuery" folder. That file will give you the ability to utilized dynamic ORDERBY clause since we don't know what column we're filtering by except on the initial load. To serialize the JSON back from the C-sharp to the JS, I incorporated the James Newton-King JSON.net DLL found here : http://json.codeplex.com/releases/view/37810. After downloading, there is a "Newtonsoft.Json.Compact.dll" which you can add in your Bin folder as a reference Here's my USING's block using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Web.UI.WebControls; using System.Web.Services; using System.Linq.Dynamic; For the Javascript references, I'm using the following scripts in respective order in case that helps some folks: 1) jquery-1.3.2.min.js ... 2) jquery-ui-1.7.2.custom.min.js ... 3) json.min.js ... 4) i18n/grid.locale-en.js ... 5) jquery.jqGrid.min.js For the CSS, I'm using jqGrid's necessities as well as the jQuery UI Theme: 1) jquery_theme/jquery-ui-1.7.2.custom.css ... 2) ui.jqgrid.css The key to getting the parameters from the JS to the WebMethod without having to parse an unserialized string on the backend or having to setup some JS logic to switch methods for different numbers of parameters was this block postData: { searchString: '', searchField: '', searchOper: '' }, Those parameters will still be set correctly when you actually do a search and then reset to empty when you "reset" or want the grid to not do any filtering Hope this helps some others!!!! Please reply if you find major issues or ways of refactoring or doing better that I haven't considered.

    Read the article

  • Async webmethod without timeout

    - by phenevo
    Hi, I need a console app which will calling webmethod. It must be asynchronous and without timeout (we don't know how much time takes this method to deal with task. Is it good way: [WebMethod] [SoapDocumentMethod(OneWay = true)] ??

    Read the article

  • ASP.NET WebMethod Returns JSON wrapped in quotes

    - by CL4NCY
    Hi, I have an asp.net page with a WebMethod on it to pass JSON back to my javascript. Bellow is the web method: [WebMethod] public static string getData(Dictionary<string, string> d) { string response = "{ \"firstname\": \"John\", \"lastname\": \"Smith\" }"; return response; } When this is returned to the client it is formatted as follows: { \"d\": \"{ \"firstname\": \"John\", \"lastname\": \"Smith\" }\" } The problem is the double quotes wrapping everything under 'd'. Is there something I've missed in the web method or some other means of returning the data without the quotes? I don't really want to be stripping it out on the client everytime. Also I've seen other articles where this doesn't happen. Any help would be appreciated thanks.

    Read the article

  • JQuery ajax call to httpget webmethod (c#) not working

    - by Tim Jarvis
    I am trying to get an ajax get to a webmethod in code behind. The problem is I keep getting the error "parserror" from the JQuery onfail method. If I change the GET to a POST everything works fine. Please see my code below. Ajax Call <script type="text/javascript"> var id = "li1234"; function AjaxGet() { $.ajax({ type: "GET", url: "webmethods.aspx/AjaxGet", data: "{ 'id' : '" + id + "'}", contentType: "application/json; charset=utf-8", dataType: "json", async: false, success: function(msg) { alert("success"); }, error: function(msg, text) { alert(text); } }); } </script> Code Behind [System.Web.Services.WebMethod] [System.Web.Script.Services.ScriptMethod(UseHttpGet = true, ResponseFormat = System.Web.Script.Services.ResponseFormat.Json)] public static string AjaxGet(string id) { return id; } Web.config <webServices> <protocols> <add name="HttpGet"/> </protocols> </webServices> The URL being used ......../webmethods.aspx/AjaxGet?{%20%27id%27%20:%20%27li1234%27} As part of the response it is returning the html for the page webmethods. Any help will be greatly appreciated.

    Read the article

  • Webmethod on my C# (server side) doesn't return data to client side (javascript)

    - by Philo
    I am using a c# Webmethod to return results to my client side written in Javascript. [WebMethod] public static string MyMethod(string Id) { SQL QUERIES and then .... // adding data to member class. Member member = new Member(Name, DOB, Sex, Member_Identification, Dates_of_services); return JsonConvert.SerializeObject(member); <-- member is a class of List strings } And on the client side you could invoke this method using the jQuery.ajax() function like this: $.ajax({ url: 'default.aspx/MyMethod', type: 'POST', contentType: 'application/json; charset=utf-8', data: JSON.stringify({ ID : ID }), success: on success { } }); function onSuccess(data) { // parses json returned data var jsondata = $.parseJSON(data.d); ..... } Now the data returned to the client side are Lists of Strings. This method works for me most times. However for one or two queries, the method runs forever without returning to the client side. On the server side however, I can use breakpoints and see that all the Lists of strings have been formed correctly. But I cannot seem to find out why they are never returned to the client side. My code reaches till the return statement on the server side and then the program just runs forever. It never reaches the function 'onsuccess' Can anyone tell me why this can happen? Anomalies in data maybe?

    Read the article

  • Is it possible to route a Webmethod?

    - by Philip
    I have a .aspx page with some Webmethods that I use for jQuery ajax calls. [WebMethod] public static string HelloWorld(string s) { return "Hello"+ s; } And call this with Url: /ajax/Test.aspx/HelloWorld I wonder if it is possible to route this method to another url like /ajax/helloworld/?

    Read the article

  • passing custom object as parameter to a webmethod of asp.net web service

    - by Jon
    Hi, I have a custom class declared as follows (in vb.net) <Serializable()> _ Public Class NumInfo Public n As String Public f As Integer Public fc As char() Public t As Integer Public tc As char() Private validFlag As Boolean = True Public Sub New() End Sub 'I also have public properties(read/write) for all the public variablesEnd Class In my service.asmx codebehind class I have a webmethod as follows: <WebMethod()> _ <XmlInclude(GetType(NumInfo))> _ Public Function ConvertTo(ByVal info As NumInfo) As String Return mbc(info)'mbc is another function defined in my service.asmx "service" class End Function The problem is that when I start debugging it to test it, the page that I get does not contain any fields where I could input the values for the public fields of numInfo. How do I initialise the class? There is no "Invoke" button either. All I see are soap details as below: ConvertToTestThe test form is only available for methods with primitive types as parameters.SOAP 1.1The following is a sample SOAP 1.1 request and response. The placeholders shown need to be replaced with actual values.POST /Converter/BC.asmx HTTP/1.1Host: localhostContent-Type: text/xml; charset=utf-8Content-Length: lengthSOAPAction: "http://Services/ConvertTo"<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <ConvertTo xmlns="http://Services/"> <info> <n>string</n> <f>int&lt/f> <fc> <char>char</char> <char>char>/char> </fc>..etc.. What am I doing wrong? For the record I tried replacing char() with string to see if it was the array causing problems but that didn't help either. I'm fairly new to web services. I tried replacing the custom object parameter with a primitive parameter just to check how things worked and it rendered a page with an input field and invoke button. I just can't seem to get it working with custom object. Help!

    Read the article

  • Passing jQuery object and WebMethod return value to an OnSuccess function

    - by iboeno
    I am calling a WebMethod from this code: if($(this).attr("checked")) { .. MyWebMethod(variable1, variable2, onSuccessFunction); } The MyWebMethod returns an integer, and I want to set $(this).attr("id") of the jQuery object above to the returned integer. Basically, I'm trying to do the equivalent of an MVC Ajax.ActionLink...AjaxOptions {UpdateTargetID =...} However, I can't figure out how to get both a reference to $(this) as well as the returned value. For example, if I do: MyWebMethod(variable1, variable2, onSuccessFunction($(this))); I can succesfully manipulate the jQuery object, but obviously it doesn't have the return value from the MyWebMethod. Alternatively, the first code block with a method signature of onSuccessFunction(returnValue) has the correct return value from MyWebMethod, but no concept of the jQuery object I'm looking for. Am I going about this all wrong?

    Read the article

  • Asp.Net(C#) Jquery Ajax with WebMethod In Public Method Call

    - by oraclee
    Hi All; Aspx Page: $(document).ready(function() { $("#btnn").click(function() { $.ajax({ type: "POST", url: "TestPage.aspx/emp", data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", success: function(msg) { } }); }); }); CodeBehind: public void grdload() { GridView1.DataSource = GetEmployee("Select * from Employee"); GridView1.DataBind(); } [WebMethod] public static void emp() { TestPage re = new TestPage(); re.grdload(); } I Can't Gridview Data Load ? How To Make GridView Data Load? Thank You

    Read the article

  • Returning a collection of objects from a webmethod

    - by Narmatha Balasundaram
    How do I return a collection of objects from a webmethod? And can this collection of objects be of different types - say of these 3 classes, private class ClassA { int A1; int A2; } private class ClassB { int B1; } private class ClassC { int C1; } ClassA objA = new ClassA(...); ClassB objB = new ClassB(...); ClassC objC = new ClassC(...); How can I return the objects, objA, objB and objC from a method?

    Read the article

  • i m trying to return list<object> from webmethod but gives error

    - by girish
    System.InvalidOperationException: There was an error generating the XML document. --- System.InvalidOperationException: The type WebService.Property.Property_Users was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically. at System.Xml.Serialization.XmlSerializationWriter.WriteTypedPrimitive(String name, String ns, Object o, Boolean xsiType) at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write1_Object(String n, String ns, Object o, Boolean isNullable, Boolean needType) at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriter1.Write8_ArrayOfAnyType(Object o) at Microsoft.Xml.Serialization.GeneratedAssembly.ListOfObjectSerializer.Serialize(Object objectToSerialize, XmlSerializationWriter writer) at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id) --- End of inner exception stack trace --- at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id) at System.Xml.Serialization.XmlSerializer.Serialize(TextWriter textWriter, Object o, XmlSerializerNamespaces namespaces) at System.Xml.Serialization.XmlSerializer.Serialize(TextWriter textWriter, Object o) at System.Web.Services.Protocols.XmlReturnWriter.Write(HttpResponse response, Stream outputStream, Object returnValue) at System.Web.Services.Protocols.HttpServerProtocol.WriteReturns(Object[] returnValues, Stream outputStream) at System.Web.Services.Protocols.WebServiceHandler.WriteReturns(Object[] returnValues) at System.Web.Services.Protocols.WebServiceHandler.Invoke() public List<object> GetDataByModuleName(string ModuleName) { List<Property_Users> obj_UserList = new List<Property_Users>(); // performing some operation that add data to obj_UserList List < Object > myList = new List<object>(); return ConvertToObjectList<Property_Users>(obj_UserList); } public List<Object> ConvertToObjectList<N>(List<N> sourceList) { List<Object> result = new List<Object>(); foreach (N item in sourceList) { result.Add(item as Object); } return result; } [WebMethod] public List<object> GetDataByModuleName(string ModuleName) { List<object> obj_list = new List<object>(); obj_list = BAL_GeneralService.GetDataByModuleName(ModuleName); return obj_list; }

    Read the article

  • string extension method - Not available through WebMethod

    - by Peter Bridger
    I've written a simple extension method for a web project, it sits in a class file called StringExtensions.cs which contains the following code: using System; using System.Collections.Generic; using System.Linq; using System.Web; /// <summary> /// Useful extensions for string /// </summary> static class StringExtensions { /// <summary> /// Is string empty /// </summary> /// <param name="value"></param> /// <returns></returns> public static bool IsEmpty(this string value) { return value.Trim().Length == 0; } } I can access this extension method from all the classes I have within the App_Code directory. However I have a web page called JSON.aspx that contains a series of [WebMethods] - within these I cannot see the extension method - I must be missing something very obvious!

    Read the article

  • WebMethod Return xml

    - by BabelFish
    I keep reading how everyone states to return XmlDocument when you want to return XML. Is there a way to return raw XML as a string? I have used many web services (written by others) that return string and the string contains XML. If you return XmlDocument how is that method consumed by users that are not on .Net? What is the method to just return the raw XML as string without it having being wrapped with <string></string> Thanks!

    Read the article

  • Read out result of a PageMethod into a jQuery-script

    - by Jan-Frederik Carl
    Hello, I am quite a jQuery novice and try to read out the result of a PageMethod into my jQuery script. I have a ScriptManager installed and the following WebMethod: [WebMethod(EnableSession = true)] public static string CheckSystemDefault(string _id) { int id = Convert.ToInt16(_id); addressTypeRepository = new AddressTypeRepository(); AddressType addressType = addressTypeRepository.GetById(id); if (addressType.IsSystemDefault == true) return "IsSystemDefault"; else return "IsNotSystemDefault"; } I use this to check if an object has the property IsSystemDefault. In the script, I hand over the id from the url and want to evaluate the result: var id = $(document).getUrlParam("id"); var check = PageMethods.CheckSystemDefault(id); if (check == "IsSystemDefault") { ... } if (check == "IsNotSystemDefault") { ... } But as a result, the variable "check" is undefined. What do I have to change?

    Read the article

  • how to send a dynamic set of parameters to webmethod using jquery ajax method?

    - by kranthi
    hi, I am using jquery ajax method on my aspx page,which will invoke the webmethod in the code behind.Currently the webmethod takes a couple of parameters like firstname,lastname,address etc which I am passing from jquery ajax method using data:JSON.stringify({fname:firstname,lname:lastname,city:city}) now my requirement has been changed such that,the number and type of parameters that are going to be passed is not fixed for ex.parameter combination can be something like fname,city or fname,city or city,lname or fname,lname,city or something else.So the webmethod should be such that it should accept any number parameters.I thought of using arrays to do so, as described here. But I do not understand how can I identify which and how many parameters have been passed to the webmethod to insert/update the data to the DB.Please could someone help me with this? thanks

    Read the article

  • how to get the individual parameters from the list of dynamic parameters in a webmethod,sent using

    - by kranthi
    hi, I am using jquery ajax method on my aspx page,which will invoke the webmethod in the code behind.Currently the webmethod takes a couple of parameters like firstname,lastname,address etc which I am passing from jquery ajax method using data:JSON.stringify({fname:firstname,lname:lastname,city:city}) now my requirement has been changed such that,the number and type of parameters that are going to be passed is not fixed for ex.parameter combination can be something like fname,city or fname,city or city,lname or fname,lname,city or something else.So the webmethod should be such that it should accept any number parameters.I thought of using arrays to do so, as described here. But I do not understand how can I identify which and how many parameters have been passed to the webmethod to insert/update the data to the DB.Please could someone help me with this? thanks

    Read the article

  • jQuery ajax call doesn't seem to do anything at all

    - by icemanind
    I am having a problem with making an ajax call in jQuery. Having done this a million times, I know I am missing something really silly here. Here is my javascript code for making the ajax call: function editEmployee(id) { $('#<%= imgNewEmployeeWait.ClientID %>').hide(); $('#divAddNewEmployeeDialog input[type=text]').val(''); $('#divAddNewEmployeeDialog select option:first-child').attr("selected", "selected"); $('#divAddNewEmployeeDialog').dialog('open'); $('#createEditEmployeeId').text(id); var inputEmp = {}; inputEmp.id = id; var jsonInputEmp = JSON.stringify(inputEmp); debugger; alert('Before Ajax Call!'); $.ajax({ type: "POST", url: "Configuration.aspx/GetEmployee", data: jsonInputEmp, contentType: "application/json; charset=utf-8", dataType: "json", success: function (msg) { alert('success'); }, error: function (msg) { alert('failure'); } }); } Here is my CS code that is trying to be called: [WebMethod] public static string GetEmployee(int id) { var employee = new Employee(id); return Newtonsoft.Json.JsonConvert.SerializeObject(employee, Newtonsoft.Json.Formatting.Indented); } When I try to run this, I do get the alert that says Before Ajax Call!. However, I never get an alert back that says success or an alert that says failure. I did go into my CS code and put a breakpoint on the GetEmployee method. The breakpoint did hit, so I know jQuery is successfully calling the method. I stepped through the method and it executed just fine with no errors. I can only assume the error is happening when the jQuery ajax call is returning from the call. Also, I looked in my event logs just to make sure there wasn't an ASPX error occurring. There is no error in the logs. I also looked at the console. There are no script errors. Anyone have any ideas what I am missing here? `

    Read the article

  • Web Services c#, Sending notifications Clients

    - by Diode
    I want to send a notification (say a string) to subscribers(subscribers ip addresses are in a database on the server side) by calling another method. when ever I call that method the output becomes error-some. [WebMethod] public string GetGroupPath(string emailAddress, string password, string ipAddress) { //SqlDataAdapter dbadapter = null; DataSet returnDS = new DataSet(); string groupName = null; string groupPath = null; SqlConnection dbconn = new SqlConnection("Server = localhost;Database=server;User ID = admin;Password = password;Trusted_Connection=false;"); dbconn.Open(); SqlCommand cmd = new SqlCommand(); string getGroupName = "select users.groupname from users where emailaddress = "+"'"+ emailAddress+"'"+ " and "+ "users.password = " + "'" +password+"'"; cmd.CommandText = getGroupName; cmd.Connection = dbconn; SqlDataReader reader = null; try { reader = cmd.ExecuteReader(); while (reader.Read()) { groupName = reader["groupname"].ToString(); } } catch (Exception) { groupPath = "Invalied"; } dbconn.Close(); dbconn.Open(); if (groupName != null) { string getPath = "select groups.grouppath from groups where groupname = " + "'" + groupName + "'"; cmd.CommandText = getPath; cmd.Connection = dbconn; try { reader = cmd.ExecuteReader(); while (reader.Read()) { groupPath = reader["grouppath"].ToString(); } } catch { groupPath = "Invalied"; } } else groupPath = "Invalied"; dbconn.Close(); if (groupPath != "Invalied") { dbconn.Open(); string getPath = "update users set users.ipaddress = "+"'"+ipAddress+"'"+" where users.emailaddress = " + "'" + emailAddress + "'"; cmd.CommandText = getPath; cmd.Connection = dbconn; cmd.ExecuteNonQuery(); dbconn.Close(); } NotifyUsers(); //NotifyUsers nu = new NotifyUsers(); //List<string> ipList = new List<string>(); //ipList.Add("192.168.56.1"); //nu.Notify(); return groupPath; } private void NotifyUsers() { Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); byte[] ipb = Encoding.ASCII.GetBytes("255.255.255.255"); IPAddress ipAddress = new IPAddress(ipb); IPEndPoint endPoint = new IPEndPoint(ipAddress, 15000); string notification = "new_update"; byte[] sendBuffer = Encoding.ASCII.GetBytes(notification); sock.SendTo(sendBuffer, endPoint); sock.Close(); } This is what has to be basically done. in the server side I have a listening thread and it gets notification when the server sends data( assume for now the database contains client ip address). then ever I call the web method it gives a error "invalid IPAddress" atline byte[] ipb = Encoding.ASCII.GetBytes("255.255.255.255"); thank you :) since this is my first ever post please be kind enough to give me a better feedback too :) thaks

    Read the article

  • 405: Method Not Allowed WCF

    - by luiscarlosch
    I can perfectly call a WCF web method from localhost. I published to this server: http://luiscarlosch.com/WebFormClean.aspx (only firefox or chrome) with the Visual Studio publishing tool and it works fine. The problem is when a try to access it from another computer. I get the 405: Method Not Allowed. But It doest make sense because It works fine when i access it remotely from the publisher computer as I said. Any idea? [ServiceContract(Namespace = "")] [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] public class ContactProxy { [WebGet()] [OperationContract] public Contact getByID(int IDContact) { Contact contact = new Contact(IDContact); return contact; } [OperationContract] public EntityData insertEntityData(int IDEntityDataFieldType, int IDContact, String value) { //Contact contact = new Contact(); // contact.insertEntityData(IDEntityDataFieldType, IDContact, value); EntityData entityData = new EntityData(); entityData.save(IDEntityDataFieldType, IDContact, value); return entityData; } } Neither method seems to work. I just noticed some user were able to access http://luiscarlosch.com/WebFormClean.aspx because they change the values. So. some clients can read the methods but some cant. This should be happening. Web Config <?xml version="1.0"?> <configuration> <configSections> </configSections> <connectionStrings> <add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" /> </connectionStrings> <system.web> <compilation debug="true" targetFramework="4.0" /> <customErrors mode="Off"/> <authentication mode="Forms"> <forms loginUrl="~/Account/Login.aspx" timeout="2880" /> </authentication> <membership> <providers> <clear/> <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" /> </providers> </membership> <profile> <providers> <clear/> <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/> </providers> </profile> <roleManager enabled="false"> <providers> <clear/> <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" /> <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" /> </providers> </roleManager> </system.web> <system.webServer> <modules runAllManagedModulesForAllRequests="true"/> </system.webServer> <system.serviceModel> <behaviors> <serviceBehaviors> <behavior name="MyServiceTypeBehaviors" > <serviceMetadata httpGetEnabled="true" /> </behavior> </serviceBehaviors> <endpointBehaviors> <behavior name="WebApplicationTest.WCFProxy.EmployeeProxyAspNetAjaxBehavior"> <enableWebScript /> </behavior> <behavior name="WebApplicationTest.WCFProxy.EntityDataFieldCollectionProxyAspNetAjaxBehavior"> <enableWebScript /> </behavior> <behavior name="WebApplicationTest.WCFProxy.Service1AspNetAjaxBehavior"> <enableWebScript /> </behavior> <behavior name="WebApplicationTest.WCFProxy.ContactProxyAspNetAjaxBehavior"> <enableWebScript /> </behavior> </endpointBehaviors> </behaviors> <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> <services> <service name="WebApplicationTest.WCFProxy.EmployeeProxy" behaviorConfiguration="MyServiceTypeBehaviors" > <endpoint address="" behaviorConfiguration="WebApplicationTest.WCFProxy.EmployeeProxyAspNetAjaxBehavior" binding="webHttpBinding" contract="WebApplicationTest.WCFProxy.EmployeeProxy" /> <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" /> </service> <service name="WebApplicationTest.WCFProxy.EntityDataFieldCollectionProxy" behaviorConfiguration="MyServiceTypeBehaviors" > <endpoint address="" behaviorConfiguration="WebApplicationTest.WCFProxy.EntityDataFieldCollectionProxyAspNetAjaxBehavior" binding="webHttpBinding" contract="WebApplicationTest.WCFProxy.EntityDataFieldCollectionProxy" /> <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" /> </service> <service name="WebApplicationTest.WCFProxy.Service1"> <endpoint address="" behaviorConfiguration="WebApplicationTest.WCFProxy.Service1AspNetAjaxBehavior" binding="webHttpBinding" contract="WebApplicationTest.WCFProxy.Service1" /> </service> <service name="WebApplicationTest.WCFProxy.ContactProxy" behaviorConfiguration="MyServiceTypeBehaviors" ><!--new--> <endpoint address="" behaviorConfiguration="WebApplicationTest.WCFProxy.ContactProxyAspNetAjaxBehavior" binding="webHttpBinding" contract="WebApplicationTest.WCFProxy.ContactProxy" /> <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" /> </service> </services> <bindings /> <client /> </system.serviceModel> </configuration>

    Read the article

  • Passing a list of ints to WebMethod using jQuery and ajax.

    - by birdus
    I'm working on a web page (ASP.NET 4.0) and am just starting simple to try and get this ajax call working (I'm an ajax/jQuery neophyte) and I'm getting an error on the call. Here's the js: var TestParams = new Object; TestParams.Items = new Object; TestParams.Items[0] = 1; TestParams.Items[1] = 5; TestParams.Items[2] = 10; var finalObj = JSON.stringify(TestParams); var _url = 'AdvancedSearch.aspx/TestMethod'; $(document).ready(function () { $.ajax({ type: "POST", url: _url, data: finalObj, contentType: "application/json; charset=utf-8", dataType: "json", success: function (msg) { $(".main").html(msg.d); }, error: function (xhr, ajaxOptions, thrownError) { alert(thrownError.toString()); } }); Here's the method in my code behind file: [Serializable] public class TestParams { public List<int> Items { get; set; } } public partial class Search : Page { [WebMethod] public static string TestMethod(TestParams testParams) { // I never hit a breakpoint in here // do some stuff // return some stuff return ""; } } Here's the stringified json I'm sending back: {"Items":{"0":1,"1":5,"2":10}} When I run it, I get this error: Microsoft JScript runtime error: 'undefined' is null or not an object It breaks on the error function. I've also tried this variation on building the json (based on a sample on a website) with this final json: var TestParams = new Object; TestParams.Positions = new Object; TestParams.Positions[0] = 1; TestParams.Positions[1] = 5; TestParams.Positions[2] = 10; var DTO = new Object; DTO.positions = TestParams; var finalObj = JSON.stringify(DTO) {"positions":{"Positions":{"0":1,"1":5,"2":10}}} Same error message. It doesn't seem like it should be hard to send a list of ints from a web page to my webmethod. Any ideas? Thanks, Jay

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >