Click here to Skip to main content
15,884,099 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have to verify the pfx file and get certificate details from the web base application but its not working after hosting the page in IIS, It only work on single machine.

-First I create an exe for the fetching the details but still its not working,

(exe saves the response in one table. And we want to fetch the response in the web Application. It is working through Code But After Hosting this is not working.)

I am fetching the data through creating the batch files.

like :

Please give me any suggestion or Idea for how to get the data from exe to web application. can any one have idea please tell me.

Thanks.

Below is my code run under code but not working after Hosting.
public string GetNSDLVerify(String panno)
    {


        StringBuilder Script_Selparties = new StringBuilder();
        Script_Selparties.AppendLine("<script language='javascript'>");
        Script_Selparties.AppendLine("alert('1');");
        Script_Selparties.AppendLine("</script>");
        Page.ClientScript.RegisterStartupScript(this.GetType(), "", Script_Selparties.ToString());

        //Page.ClientScript.RegisterStartupScript(Me.GetType, "", Script_Selparties.ToString)
        String srcpathdCsdl = Server.MapPath("../CCRSDOCUMENTS");
        //X509Certificate2 X509Certificate2;
        String t1 = srcpathdCsdl + "/" + System.Configuration.ConfigurationManager.AppSettings["CertName"];
        String t2 = System.Configuration.ConfigurationManager.AppSettings["CertPswd"];
        X509Certificate2 x = new X509Certificate2(t1, t2);
        System.Text.ASCIIEncoding encodingc = new System.Text.ASCIIEncoding();

        //Script_Selparties = "";
        //Script_Selparties.AppendLine("<script language='javascript'>");
        //Script_Selparties.AppendLine("alert('2');");
        //Script_Selparties.AppendLine("</script>");
        //Page.ClientScript.RegisterStartupScript(this.GetType(), "", Script_Selparties.ToString);


        string dataReg;
        dataReg = System.Configuration.ConfigurationManager.AppSettings["RegisteredID"] + "^" + panno;


        byte[] bytes = encodingc.GetBytes(dataReg);

        //byte[] sig=Sign(bytes, x);

        //if (data == null)
        //    throw new ArgumentNullException("data");
        //if (certificate == null)
        //    throw new ArgumentNullException("certificate");

        // setup the data to sign

        ContentInfo content = new ContentInfo(bytes);

        SignedCms signedCms = new SignedCms(content, false);

        CmsSigner signer = new CmsSigner(SubjectIdentifierType.IssuerAndSerialNumber, x);


        // create the signature        

        signedCms.ComputeSignature(signer, false); // issue is here only
        //string Response1 = "1^webpart121112";
        //return Response1;
        byte[] sig = signedCms.Encode();

        String sigi = Convert.ToBase64String(sig);

        //'Post data
        System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
        StringBuilder postData = new StringBuilder();
        postData.Append("data=" + dataReg);
        postData.Append("&signature=" + System.Web.HttpUtility.UrlEncode(sigi));

        //Script_Selparties = "";
        //Script_Selparties.AppendLine("<script language='javascript'>");
        //Script_Selparties.AppendLine("alert('3');");
        //Script_Selparties.AppendLine("</script>");
        //Page.ClientScript.RegisterStartupScript(this.GetType(), "", Script_Selparties.ToString);
        //'postData.Append("q=amit&rls=com.microsoft:en-us&ie=UTF-8&oe=UTF-8&startIndex=&startPage=1&redir_esc=&ei=odEuTcDtKYvtrQeQ07DfCg");


        //'byte[] data = encoding.GetBytes(postData.ToString());
        byte[] data = encodingc.GetBytes(postData.ToString());
        //Script_Selparties = "";
        //Script_Selparties.AppendLine("<script language='javascript'>");
        //Script_Selparties.AppendLine("alert('4');");
        //Script_Selparties.AppendLine("</script>");
        //Page.ClientScript.RegisterStartupScript(this.GetType(), "", Script_Selparties.ToString);
        //'Prepare web request...
        //'HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create("https://59.163.46.2/TIN/PanInquiryBackEnd");
        HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create("https://59.163.46.2/TIN/PanInquiryBackEnd");
       
        //'HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create("http://www.google.co.in/search");
        myRequest.Method = "POST";
        myRequest.ContentType = "application/x-www-form-urlencoded";
        myRequest.ContentLength = data.Length;

        ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(AcceptAllCertifications);
        //Script_Selparties='';
        //Script_Selparties.AppendLine("<script language='javascript'>");
        //Script_Selparties.AppendLine("alert('5');");
        //Script_Selparties.AppendLine("</script>");
        //page.ClientScript.RegisterStartupScript(this.GetType(), "", Script_Selparties);    
        Stream newStream = myRequest.GetRequestStream();
        // Send the data.
        newStream.Write(data, 0, data.Length);
        Console.WriteLine("Send");

        //Now, we read the response (the string), and output it.  
        HttpWebResponse WebResp = (HttpWebResponse)myRequest.GetResponse();
        Stream Answer = WebResp.GetResponseStream();
        StreamReader _Answer = new StreamReader(Answer);
        Console.WriteLine("Received");
        //var Response= _Answer.ReadToEnd();
        string Response = _Answer.ReadToEnd();
        newStream.Close();
        return Response;
    }

IS My Code which is Working fine in Code behind but not working after Hosting.
please give me Suggestion

Regards,
Atul
Posted
Updated 7-Jul-14 8:20am
v2
Comments
[no name] 7-Jul-14 14:21pm    
where is the problem coming after host and what type of error

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900