Call WebMethod Using PowerShell?

Mar 31, 2010

It seems like ASP.NET WebMethods are not "web servicey" enough to work with New-WebServiceProxy. Or maybe it is, and I haven't figured out how to initialize it?

So instead, I tried doing it manually, like so:

$wc = new-object System.Net.WebClient
$wc.Credentials = [System.Net.CredentialCache]::DefaultCredentials
$url = "http://www.domenicdenicola.com/AboutMe/SleepLog/default.aspx/GetSpans"
$postData = "{`"starting`":`"/Date(1254121200000)/`",`"ending`":`"/Date(1270018800000)/`"}"
$result = $wc.UploadString($url, $postData)

But this gives me "The remote server returned an error: (500) Internal Server Error." So I must be doing something slightly wrong.

how to call my PageMethod from PowerShell, and not get an error?

View 2 Replies


Similar Messages:

Web Forms :: WebMethod Call Won't Return Seems Blocked By Other Iframe Call?

Oct 8, 2010

XP Pro,aspnet 2, IIS, Oracle I have a primary webpage that displays a tab and some summary data. The tab uses an iframe and the summary data is loaded by an async WebMethod call back to C#. The iframe page takes a short while to load depending on how much data is in there (sometimes upto 20 seconds?). The WebMethod call, or at least the content of it, is very fast. BUT, the WebMethod call won't return until basically the iframe has finished loading.

I've verified through Fiddler that the browser is initiating both requests at basically the same time. It's initiating the iframe call first followed immediately by the WebMethod call within the same second. My understanding is that browsers are limited to only two calls at once.

If I set a breakpoint at the end of my WebMethod call (even commenting out ALL it's guts so it just returns an empty string), that breakpoint won't fire until the aspnet page serving up the iframe has finished. Using threads window, I see both calls at the server. I just don't understand why the server won't actually run the Webmethod call until the first call has finished. I've searched the code looking Monitor.Enter, lock, etc to make sure nobody has inserted any other type of blocking code and I can't find anything. I've basically emptied out the WebMethod call and it just returns a string, but no matter what I do, it just won't return as fast as it can. If I comment out the iframe, then the WebMethod call returns within 2 seconds. With the iframe, it "looks" like the the webmethod call won't return until the iframe has finished.

1) Does aspnet only process one request per aspnet session id? Is it FIFO? I figured the webserver would just process requests and return each request as fast as it can.

2) What else can I do to get that summary data to return faster (but not actually loading and putting the data into the very first primary page) ?

View 2 Replies

WCF / ASMX :: Multiple Call To Same Webmethod In Same Call?

Sep 17, 2010

INFO: IIS 7+ .NET 4.0

I have a webservice with a webmethod

[Code]....

I call it with

[Code]....

But the "InsertUpdateCategory" only execute the last part of the call specified (the one with Id 6), the first don't get executed

View 1 Replies

Cannot Call Webmethod From JQuery

Nov 8, 2010

I cannot call webmethod from jquery. I think its about web.config file. How can i set web.config file for web services and webmethod?

View 1 Replies

How To Call WebMethod For Control In Javascript

Jan 27, 2011

I'm trying to call a WebMethod (GetData()) for a control in a web page using javascript.

<script type="text/javascript">
$(document).ready(function () {
//this selector needs fixed
$('<%= Control1.ClientID %>').GetData(); });
</script>
<tel:RadScriptManager ID="RadScriptManager1" runat="server" />
<tel:RadAjaxPanel ID="RadAjaxPanel1" runat="server" LoadingPanelID="RadAjaxLoadingPanel1">
<uc1:Control ID="Control1" runat="server" />
</tel:RadAjaxPanel>

The uc:Control code:
[WebMethod()] [ScriptMethod()]
protected void LoadData() {
//stuff happens here }

I can't figure out what kind of selector to use. I have multiple controls on the page, and I want to call them at different times. What kind of selector or what command do I use to run this WebMethod?

View 4 Replies

AJAX :: How To Call WebMethod Using AngularJS

May 7, 2015

I am trying to create a function that when a button is clicked it will pass all my records to my json page which will save my data. This is what i have so far

var t = this;
t.RecordsSave = function ($http) {
for (var i = 0; i <t.records.length; i++) {
var record=t.recordss[i];
var data = params( {
record: record.Number[i],

[Code] ....

I get the following error "params is not defined"

and "Cannot read property '0' of undefined"

How should i go about this. not familiar with angular js

View 1 Replies

WCF / ASMX :: Increase The Timeout Of Webmethod Call?

Mar 25, 2010

In my web app, if user clicks a button, I have to kick off a long running task. I have to keep the user informed about the status of execution of the task from time to time. To accomplish this, I create a thread on button click which makes a synchronous webservice call. The webmethod works on a long running task; while the main thread informs the users about the status of execution.

Currently the webmethod call times out in approximately 90 seconds. I want to increase the timeout to 10 mins. I tried setting <httpRuntime executionTimeout="600"/> along with debug="false"; but in vein. Can anyone tell me what I am missing?

View 3 Replies

Jquery - JQGrid - Cannot Call WebMethod But Can With Ajax

Mar 1, 2011

I am new to jqGrid and I have found it difficult to follow the documentation jqGrid Documentation / I cannot figure out how to call a WebMethod when setting up the JQGrid. I have been successful in making an Ajax call to get the data and then setting up the JQGrid with local data. I think its an extra step in the setup process and that I should be able to provide the path to the webmethod using the url property. The editurl property is the same way. I am never actually receiving the post to the server. Attempted JQGrid Setup

function GetData()
{
$('#list').jqGrid({
type: "POST",
url: "Default.aspx/GetUsersJSON",
datatype: "json",
height: 250,
colName: ['Username', 'Email'],
colModel: [
...
}).jqGrid(
'navGrid',
'#pager',
{
edit: true,
add: true,
del: true
});
}
WebMethod
[WebMethod]
public static string GetUsersJSON()
{
var users = new List();
using(UserAdministrationSandboxDataContext uasd = new UserAdministrationSandboxDataContext())
{
users = uasd.GetUserList();
}
JavaScriptSerializer serializer = new JavaScriptSerializer();
return serializer.Serialize(users);
}

Current Code I got it working correctly now, but I still have one final question. Why did I have to set the 'repeatitems: false' in order to display the content? Some of the caveats to get this to work include the different ways to setup the ajax request. (Ajax: type) is (jqgrid : mtype) (Ajax: contentType) is (jqgrid : ajaxGridOptions: { contentType: })

And finally understanding the documentation from the documentation on how to setup the JSONReader.

function GetUserDataFromServer()
{
$('#list').jqGrid({
url: "Default.aspx/GetUsersJSON",
mtype: 'POST',
ajaxGridOptions: { contentType: "application/json" },
datatype: "json",
serializeGridData: function (postData)
{
return JSON.stringify(postData);
},
jsonReader: {
root: function (obj) { return obj.d; },
page: function (obj) { return 1; },
total: function (obj) { return 1; },
records: function (obj) { return obj.d.length; },
id:'0',
cell:'',
repeatitems: false
},
datatype: "json",
height: 250,
colName: ['Username', 'Email'],
colModel: [
{
name: 'Username',
index: 'Username',
width: 100,
editable: true
},
{
name: 'Email',
index: 'Email',
width: 220,
editable: true
},
{
name: 'IsLockedOut',
index: 'IsLockedOut',
width: 100,
editable: true,
edittype: 'checkbox'
}
],
caption: "Users"
})
}
Web Method
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static List GetUsersJSON()
{
using (UserAdministrationSandboxDataContext uasd = new UserAdministrationSandboxDataContext())
{
return uasd.GetUserList();
}
}
One JSON Object from the List
{"__type":"UserAdministrationSandbox.UserData","PKID":"00000000-0000-0000-0000-000000000001","Username":"TestUser","ApplicationName":"Test","Email":"TestUser@test.com","Comment":"TestUser","Password":"D41D8CD98F00B204E9800998ECF8427E","PasswordQuestion":"Is this a blank Password?","PasswordAnswer":null,"IsApproved":true,"LastActivityDate":"/Date(1298869200000)/","LastLoginDate":"/Date(1298869200000)/","LastPasswordChangedDate":"/Date(1298869200000)/","CreationDate":"/Date(1298869200000)/","IsOnLine":false,"IsLockedOut":false,"LastLockedOutDate":"/Date(1298869200000)/","FailedPasswordAttemptCount":0,"FailedPasswordAttemptWindowStart":null,"FailedPasswordAnswerAttemptCount":null,"FailedPasswordAnswerAttemptWindowStart":null}

View 1 Replies

JQuery :: Accessing Webmethod Via Ajax Call

Jul 6, 2010

I have 2 web pages edit.aspx and webmethods.apx. In edit.aspx there is some jquery code to get some data :

[Code]....

With this I try to get a Json object from the webmethods.aspx page :

[Code]....

I get an error back that says "Parser Error", I even did put an breakpoint on the webmethod but it is like it's never triggered. Is my url wrong if I'm in the following url :

[Code]....

Should I use something like ../WebMethods.aspx?

View 6 Replies

Use The GridView (server Control) From A Webmethod And Call It Via Jquery?

Nov 26, 2010

I am currently working with ASP.NET and the person who designed the form has used all Server Controls for things like TextBoxes and Dropdowns etc when really they are not providing postbacks.. Some of the dropdowns and textboxes are values that I need only in jQuery so as far as I can see there are no drawbacks to coverting these controls to standard html controls rather than ASP.NET server controls?

I suppose I will need to continue to have my GetDataGrid button as a server control because I will need it to postback (and receive PageLoad events etc - all asp.net events) to update the GridView? Or would it be possible to use the GridView (server control) from a Webmethod and call it via Jquery?

Of course in my webmethod I would need to the instance of the gridview to add the datasource - but I don't see how this would be possible without being in the ASP.NET events - or maybe I wrong?

The other thing I thought of was changing the GetGridView button to a standard HTML and calling the javascript postback from the client click event?? This way it would do a real postback and I would end up in Page_load.

Taking everything into effect i don't want to the change the GridView asp.net control as it funcions well as an asp.net server control but i am unsure how i would do this.

I remember a document being available that said "how to use asp.net webforms without server controls" but i can't seem to find it. I suppose using webforms like asp.net MVC - but i can't change the project to MVC - its out of my control.

View 3 Replies

Jquery Ajax With WebMethod In Public Method Call

Mar 25, 2010

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?

View 3 Replies

Spring.net And Nhibernate And Jquery Ajax Call To Webmethod At Codebehind?

Jan 28, 2011

I am trying to make a jquery ajax call to a static method on the codebehind file. The problem is that ArtistManager injected by Spring is not static and I cannot use it in the static webmethod. I am looking for any ideas on how to implement this

ArtistList.aspx

[code]....

View 2 Replies

AJAX :: Invalid Hexadecimal Character Returned By Webmethod Call?

Mar 8, 2010

I have a 2007 excel addin app (VS2005) which calls a web service (also developed in VS2005). When the webservice returns a large amount of data I get the following exception

System.InvalidOperationException: There is an error in XML document (1, 14493956). ---> System.Xml.XmlException: '', hexadecimal value 0x1C, is an invalid character. Line 1, position 14493956.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)

[code]...

View 2 Replies

AJAX :: Is It Possible To Call A Custom Method Or Class Before Accessing Webmethod From PageMethods

Jan 19, 2010

is it possible to call a custom method or class before accessing webmethod from pageMethods ?

View 2 Replies

Web Forms :: Call MsCaptcha Control In Static WebMethod Jquery Ajax

Dec 1, 2010

I want to call MsCaptcha Control in Static WebMethod,for validating. so,I want to check mscaptcha value in javascript or jquery without refresh the page.I think it is my solution that i use JqueryAjax.

View 7 Replies

Add Record Via Jquery Ajax Call To Webmethod And Update Dropdown List

Jan 26, 2010

i manage to add recrod via jquery ajax call to webmethod but i want to update the dropdown list once the record is been added. i dont want to use update panel. what would be the best way of doing that.

View 2 Replies

Web Forms :: Error While Accessing Page Label Control In WebMethod During AJAX PageMethods Call

Jul 16, 2012

I found this Article from link : [URL] .... that explains how to call server-side Method from javascript,

I used your code, my server-side function is static, public, and also I added

[System.Web.Services.WebMethod] 
and
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">

View 1 Replies

(C#) Jquery "make Return String" Ajax With WebMethod Call

Mar 25, 2010

[WebMethod]
public static string emp()
{
return "BlaBla";
}
Aspx Page:
$(document).ready(function() {
$.get("TestPage.aspx/emp", null, function(data) {
alert(data);
})
})
Message Box Output: TestPage.aspx on the page codes
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>
</title>
<style>
tr
{
background-color: red;
color: White;
}
</style>

How to make return string?

View 1 Replies

AJAX :: ASPX WebMethod Not Running The WebService Webmethod Returning The Page?

May 19, 2010

I have a service that works great on my development box. It uses JQuery to hit my web service, and then the JSON results are sent back.

The web service is located on our basePage.cs. We didn't want to put out an external WebService for this. Our on beta box something different is happening.

The web page seems to be trying to call the web method correctly - the JSON data is being sent... but the server doesn't seem to know it's a webmethod. here's my service function (it's in our basepage.cs which inherits from Page).

[Code]....

View 2 Replies

Powershell From C#?

Aug 5, 2010

I am trying to write an asp program to automate some tasks in the office - namely creating a mail-enabled contact. The code is:

RunspaceConfiguration runspaceConfig = RunspaceConfiguration.Create();PSSnapInException PSException = null;PSSnapInInfo info = RunspaceConfig.AddPSSnapIn("Microsoft.Exchange.Management.Powershell.Admin", out PSException);Runspace runspace = RunspaceFactory.CreateRunspace(runspaceConfig);runspace.Open();Pipeline pipeline = runspace.CreatePipeline();Command command = new Command("New-MailContact");command.Parameters.Add("Name", "TestName");command.Parameters.Add("ExternalEmailAddress", "testname@testdomain.com");command.Parameters.Add("OrganizationalUnit",

[code]....

View 2 Replies

WCF / ASMX :: PowerShell In Web Service For Ajax Requests?

Dec 9, 2010

A customer wants us to create an ajax-enabled web application that can be used to manage their IT environment (Active directory, mail, file security, ...). However, as the team that will support the web application does not know anything about these IT systems, they would like to split the coding so that all interfacing with the IT environment is done via PowerShell, which is known by the administrators of these systems. This would mean that if new functionality is required, the web team can just create an additional web page and interface and use PowerShell scripts that get created by technically skilled people in that specific topic (ie mail administrators). I don't see an issue using this approach for requests like adding a user where latency is not an issue, but I do wonder if this is feasible for interactive content with Ajax.

Ie I would like to implement a google suggest like search for AD users. This would mean that ie for every x keystrokes (or x seconds whatever approach I implement) an Ajax request will be made and the web application or web service will than use PowerShell to get the data. Taken into account that up to about 75 users can use this feature, is this something that would work? Not only performace-wise but also the number of connections (I read about the Powershell 5 remote session limit but also that it could be put to a higher number)? The example above is probably the most resource heavy Ajax requests (and can be optimized by caching), so taken into account they don't want this nice feature, are basic PowerShell scripts in ajax request really an option. My gut feeling is telling me this is a no-go, but I don't want to exclude the option just because it's not something I usually would do.

View 1 Replies

Developed .NET MVC Web Application To Execute PowerShell Scripts?

Apr 16, 2010

I have developed an ASP.NET MVC Web Application to execute PowerShell scripts.I am using the VS web server and can execute scripts fine. However, a requirement is that users are able to execute scripts against AD to perform actions that their own user accounts are not allowed to do.Therefore I am using impersonation to switch the identity before creating the PowerShell runspace:

Runspace runspace = RunspaceFactory.CreateRunspace(config);
var currentuser = WindowsIdentity.GetCurrent().Name;
if (runspace.RunspaceStateInfo.State == RunspaceState.BeforeOpen) {
runspace.Open();
}

I have tested using a domain admin account and I get the following exception when calling runspace.Open():

Security Exception
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.
Exception Details: System.Security.SecurityException: Requested registry access is not allowed.

The web application is running in full trust and I have explicitly added the account I am using for impersonation to the local administrators group of the machine (even though the domain admins group was already there).I'm using advapi32.dll LogonUser call to perform the impersonation in a similar way to this post (http://blogs.msdn.com/webdav_101/archive/2008/09/25/howto-calling-exchange-powershell-from-an-impersonated-thead.aspx)

View 1 Replies

Hosting Powershell In .net Mvc Running In Iis To Provide CLI For Custom Tasks?

Aug 22, 2010

I need CLI for our asp.net mvc application to perform maintenance tasks and some status tasks.

I think powershell is designed to provide CLI. But i do not know anything about it other than name.

How can i host powershell in asp.net mvc running in iis to provide CLI for custom tasks?

View 2 Replies

Configuration :: Unable To use Namespaces in Order To Run A Powershell Script?

Jun 29, 2010

I am not able to use the below namespaces in order to Run a powershell script:

using
System.Management.Automation;
using
System.Management.Automation.Runspaces;

I have installed Windows Powershell 2 and the framework is 2.0. I have added the referenece System.Management in the web.config file. Also i have browsed the above 2 namespaces and added to the project in add reference tab. Still i get the below message:

CS0234: The type or namespace name 'Automation' does not exist in the namespace 'System.Management' (are you missing an assembly reference?)

View 6 Replies

Execute Powershell Commands On Windows 2008 Server From Application?

Nov 26, 2010

I want to execute some powershell commands on a remote windows 2008 machine. Right now i am using psexec to run the powershell from c# asp.net application. I would like to know is there any way to execute powershell commands without using a third party tool like psexec?

View 1 Replies







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