32597

can a MVC 3 app execute an Action in a different app on the same server

Question:

I have two asp.net applications running on one server, one is MVC-3, the other is not. the MVC application has a POST action which sends an email and returns a JSON object. Can the plain asp.net application somehow execute the action (from server) and receive the JSON object? I guess it just needs to execute a POST somehow?

Answer1:

Found the answer: It is the method HttpWebRequest, used as follows.

string data = "data to post"; HttpWebRequest request = (HttpWebRequest)WebRequest.Create("put URL here"); // set post headers request.Method = "POST"; request.KeepAlive = true; request.ContentLength = data.Length; request.ContentType = "application/x-www-form-urlencoded"; System.IO.StreamWriter writer = new System.IO.StreamWriter(request.GetRequestStream()); writer.Write(data); writer.Close(); writer.Dispose(); // next line posts the data to the URL HttpWebResponse response = (HttpWebResponse)request.GetResponse();

Recommend

  • Dynamically Create Folders and Subfolders
  • Youtube v3 api 401 Unauthorized
  • Get number of monthly searches for specific keywords using Google Adwords API for .NET
  • Uploading into folder in FTP?
  • Google Chrome Plugin development - Monitor network requests?
  • GCM push notification with C# asp.net giving null as notification in android devices
  • How do I connect to the Asana Rest API using c#?
  • Selenium ChromeDriver (C#) Crashes Only in Visual Studio Debug Mode
  • .Net Compact Framework 3.5 HTTP POST
  • receiving X509 client certificates in web requests
  • Conversion of VB6 HTTP request to VB.Net 2.0
  • How can I let users share their location in Bot Framework webchat channel?
  • read values from form post in jquery or javascript
  • apply a javascript function to draggable copy
  • Consuming a WCF service in a Java Client using wsHttpBinding
  • Magento site down due to mysql error General error: 1030 Got error -1 from storage engine
  • HttpURLConnection Closing IO Streams
  • Exception gevent.hub.LoopExit: LoopExit('This operation would block forever',)
  • netsh acl setting (need alternative method - registry settings?)
  • How to 'create temp table as select' in Slick?
  • how to set variables in a php include file?
  • Security issues with PHP's Readfile method
  • Parsing a CSV string while ignoring commas inside the individual columns
  • onBackPressed() not being executed
  • Recording logins for password protected directories
  • SignalR .NET Client Invoke throws an exception
  • How to redirect a user to a different server and include HTTP basic authentication credentials?
  • Trying to switch camera back to front but getting exception
  • Symfony2: How to get request parameter
  • Jquery - Jquery Wysiwyg return html as a string
  • Delete MySQLi record without showing the id in the URL
  • Arrays break string types in Julia
  • WPF Applying a trigger on binding failure
  • log4net write single file for each call to log.info
  • Free memory of cv::Mat loaded using FileStorage API
  • Getting error when using KSoap library to consume .NET web services
  • Angular 2 constructor injection vs direct access
  • Java static initializers and reflection
  • Exception on Android 4.0 `android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode)`
  • Programmatically clearing map cache