Click here to Skip to main content
15,892,005 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionIIS gets Access Forbiden error [modified] Pin
beatles169227-Jul-07 12:19
beatles169227-Jul-07 12:19 
AnswerRe: IIS gets Access Forbiden error Pin
beatles169227-Jul-07 12:46
beatles169227-Jul-07 12:46 
AnswerRe: IIS gets Access Forbiden error Pin
Paul Conrad27-Jul-07 19:40
professionalPaul Conrad27-Jul-07 19:40 
Questionadding and removing table rows dynamically Pin
jojoStoneHead27-Jul-07 10:57
jojoStoneHead27-Jul-07 10:57 
AnswerRe: adding and removing table rows dynamically Pin
Christian Graus27-Jul-07 11:30
protectorChristian Graus27-Jul-07 11:30 
AnswerRe: adding and removing table rows dynamically Pin
jojoStoneHead27-Jul-07 13:38
jojoStoneHead27-Jul-07 13:38 
AnswerRe: adding and removing table rows dynamically Pin
Imran Khan Pathan27-Jul-07 23:24
Imran Khan Pathan27-Jul-07 23:24 
QuestionAdding a username/ password to http-post in a console application Pin
rbreault27-Jul-07 10:39
rbreault27-Jul-07 10:39 
I have the following application, I need to supply a username and a password to perform my http-post and don't understand where to start with that can someone look at the following code and point me in the write direction or an example. Thank you

using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Web;
using System.IO;
using System.Security.Cryptography.X509Certificates;

namespace postDT
{
class SimpleHttpClient
{


//private string GetPostdata()
//{
// string boundary = "boundary=---------------------------7d2e2c76e104be" + this._Boundary;
// int arrRegs = this._ParamsCollection.Count * 5;
// string[] auxReqBody = new string[arrRegs];
// int count = 0;
// foreach(ParamsStruct par in this.ParamsCollection)
// {
// auxReqBody[count] = boundary;
// count++;
// switch (par.Type)
// {
// case ParamsStruct.ParamType.File:
// {
// auxReqBody[count] = "Content-Disposition: file; name=\"" + par.Name + "\"; filename=\"" + par.GetOnlyFileName() + "\"";
// count++;
// auxReqBody[count] = "Content-Type: text/plain";
// count++;
// auxReqBody[count] = "";
// count++;
// auxReqBody[count] = par.StringValue;
// count++;
// break;
// }
// case ParamStruct.ParamType.Parameter:
// default:
// {
// auxReqBody[count] = "COntent-Disposition: form-data; name=\"" + par.Name + "\"";
// count++;
// auxReqBody[count] = "";
// count++;
// auxReqBody[count] = par.StringValue;
// count++;
// break;
// }
// }
// }
// auxReqBody[count] = boundary;
// count++;
// string requestBody = String.Join("\r\n",auxReqBody);
// return requestBody;
//}




[STAThread]
public static void Main(string[] args)
{
string gatewayUrl = "https://www.qa.dealertrack.com/DealerFeed/DealerFileUpload.asp";
string inputFilePath = "Z:/ZQ1412JPM/dealers.csv";
string DERCertFilePath = "C:/Documents and Settings/rbreault/Desktop/qa.dt.cer";
HttpWebResponse resp = null;

try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(gatewayUrl);
Console.WriteLine("Connecting to URL: " + gatewayUrl);
// Read DER encoded client certificate and attach it to request object
// so it can be passed to the gateway as part of the SSL handshake
X509Certificate clientcert = X509Certificate.CreateFromCertFile(DERCertFilePath);
request.ClientCertificates.Add(clientcert);

// Read input from file
string inputData;
using (StreamReader inputFileReader = new StreamReader(inputFilePath))
{
inputData = inputFileReader.ReadToEnd();
}

Console.WriteLine("input file value:");
Console.WriteLine(inputData);

// encocde post data and set up the request NOTE: input data is passed as a parameter named 'boundry'
string postData = "boundry=---------------------------7d2e2c76e104be" + inputData + "-----------------------------7d2e2c76e104be--";
byte[] postDataBytes = Encoding.UTF8.GetBytes(postData);
request.Method = "POST";
request.ContentType = "multipart/form-data";
request.ContentLength = postDataBytes.Length;
Stream requestStream = request.GetRequestStream();
requestStream.Write(postDataBytes, 0 ,postDataBytes.Length);
requestStream.Close();

// get response and write to console
resp = (HttpWebResponse)request.GetResponse();
Console.WriteLine("Got a response from the file Gateway, response:");
StreamReader responseReader = new StreamReader(resp.GetResponseStream(), Encoding.UTF8);
Console.WriteLine(responseReader.ReadToEnd());

resp.Close();

}
catch(Exception e)
{
Console.WriteLine( e.ToString());
Console.WriteLine("\r\nThe request URI could not be found or was malformed");
}
finally
{
if ( resp != null )
{
resp.Close();
}
}
}
}
}

AnswerRe: Adding a username/ password to http-post in a console application Pin
Paul Conrad27-Jul-07 19:41
professionalPaul Conrad27-Jul-07 19:41 
GeneralRe: Adding a username/ password to http-post in a console application Pin
rbreault27-Jul-07 19:43
rbreault27-Jul-07 19:43 
GeneralRe: Adding a username/ password to http-post in a console application Pin
Paul Conrad27-Jul-07 19:49
professionalPaul Conrad27-Jul-07 19:49 
QuestionDate formatting Pin
Hasan Ali27-Jul-07 10:22
Hasan Ali27-Jul-07 10:22 
AnswerRe: Date formatting Pin
Hasan Ali27-Jul-07 10:27
Hasan Ali27-Jul-07 10:27 
GeneralRe: Date formatting Pin
Hasan Ali27-Jul-07 10:45
Hasan Ali27-Jul-07 10:45 
GeneralRe: Date formatting Pin
Hasan Ali27-Jul-07 10:51
Hasan Ali27-Jul-07 10:51 
AnswerRe: Date formatting Pin
Paul Conrad27-Jul-07 10:40
professionalPaul Conrad27-Jul-07 10:40 
AnswerRe: Date formatting Pin
Christian Graus27-Jul-07 14:22
protectorChristian Graus27-Jul-07 14:22 
Questionhow can i update the gridview with ajax???? Pin
mr.mohsen27-Jul-07 9:37
mr.mohsen27-Jul-07 9:37 
AnswerRe: how can i update the gridview with ajax???? Pin
Christian Graus27-Jul-07 11:26
protectorChristian Graus27-Jul-07 11:26 
Questiondecrease online users Pin
mr.mohsen27-Jul-07 9:33
mr.mohsen27-Jul-07 9:33 
AnswerRe: decrease online users Pin
Paul Conrad27-Jul-07 9:42
professionalPaul Conrad27-Jul-07 9:42 
GeneralRe: decrease online users Pin
mr.mohsen27-Jul-07 9:49
mr.mohsen27-Jul-07 9:49 
GeneralRe: decrease online users Pin
Cfer8327-Jul-07 10:02
Cfer8327-Jul-07 10:02 
GeneralRe: decrease online users Pin
Paul Conrad27-Jul-07 10:12
professionalPaul Conrad27-Jul-07 10:12 
AnswerRe: decrease online users Pin
T.EDY27-Jul-07 16:56
T.EDY27-Jul-07 16:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.