Skip to content

Convert aspx.cs code into .net core api?

Harish Batchu

Asked Sep 12, 2019, 7:04 AM EDT1 answer
Share
LinkedInX
How to convert below code into dotnet core? 
 
TypeScript
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.IO;
using CCA.Util;
using System.Collections.Specialized;
using System.Xml;

namespace GetRSA_Kit
{
    public partial class GetRSA : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
		string queryUrl = "https://secure.ccavenue.com/transaction/getRSAKey";
		string vParams = "";
		foreach (string key in Request.Params.AllKeys){
			vParams += key + "=" + Request[key] + "&";
		}
                // Url Connection
                String message = postPaymentRequestToGateway(queryUrl, vParams);
                Response.Write(message);
            }
            catch (Exception exp){
                Response.Write("Exception " + exp);
            }
        }

        private string postPaymentRequestToGateway(String queryUrl, String urlParam)
        {
            String message = "";
            try
            {
StreamWriter myWriter = null;// it will open a http connection with provided url
WebRequest objRequest = WebRequest.Create(queryUrl);//send data using objxmlhttp object
Bash
                objRequest.Method = "POST";
                //objRequest.ContentLength = TranRequest.Length;
                objRequest.ContentType = "application/x-www-form-urlencoded";//to set content type
                myWriter = new System.IO.StreamWriter(objRequest.GetRequestStream());
myWriter.Write(urlParam);//send data
myWriter.Close();//closed the myWriter object
Java
                // Getting Response
                System.Net.HttpWebResponse objResponse = (System.Net.HttpWebResponse)objRequest.GetResponse();//receive the responce from objxmlhttp object
                using (System.IO.StreamReader sr = new System.IO.StreamReader(objResponse.GetResponseStream()))
                {
                    message = sr.ReadToEnd();
                }
            }
            catch (Exception exception)
            {
                Console.Write("Exception occured while connection." + exception);
            }
            return message;
        }
    }
}

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    You project not run .net core  
    if yes then 
    Try to  
    First you install docker then update mocrosoft visual studio 2017 then run .
    0