|
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();
}
}
}
}
}
|
|
|
|
|
What exactly is your problem?
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
I get a 401 error. I need to pass a username and password but I am unsure where to add it to my code.
|
|
|
|
|
Who did the website that you are trying to log to? You may want to direct your question to them, unless it was you that did the site
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
I have string = "5/8/2007 2:42:32.316425" got it from database
I want to convert it to .NET date object with all fraction second in it.
If any one knows Please let me know.
Thanks
Mohamed
|
|
|
|
|
DateTime dta;
dta = Convert.ToDateTime(DateTime.Now.ToString("MM/dd/yyyy");
|
|
|
|
|
DateTime dta;
dta = Convert.ToDateTime(DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss.ffffff"));
String ms = dta.Millisecond.ToString();
|
|
|
|
|
DateTime dta;
dta = Convert.ToDateTime(DateTime.Now.ToString("MM/dd/yyyy HH:mm:ss.ffffff"));
String hhh = dta.ToString("MM/dd/yyyy HH:mm:ss.ffffff");
String ms = dta.Millisecond.ToString();
|
|
|
|
|
Hasan Ali wrote: with all fraction second in it
Elaborate a bit more, please...
Do you mean something like 5/8/2007 2:42:32 1/3"?
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
You really should store datas as dates in your database, not as strings.
DateTime.TryParse is your best bet.
BTW, it took me a day to help you because at first glance your (mostly meaningless) replies made me think someone had helped you.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
hello friends
i use ajax in my website...
i want to update my gridview or datagrid or every components that behavior like these with ajax method but i dont know how i can do it?
please help me.
thank you.
www.toolsfa.com==>msma
|
|
|
|
|
A grid view is a server side construct. On the client side, it's just a table. So, you can add to your table using AJAX, I assume the AJAX call gets or stores the data ? What do you know about how to use AJAX ?
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
hi my friends
i used a method to increase the online users of my website and it work correctly.
but i need to decrease the online users when a user close my website, but i can't do it.
please help me if anybody know...
thank you.
www.toolsfa.com==>msma
|
|
|
|
|
How are you doing this? Your question really doesn't make a whole lot of sense.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
dear paul
i use start_application or start_session method in global file for increasing the online users
but when i use end_application or end_session method for decreasing the online users it does not work. do you know where i made a mistake
thank you
www.toolsfa.com==>msma
|
|
|
|
|
Support for Session End is not very good and i've seen this question asked many times.
One you may try, is setup a timer, if the timer expires without any user activity, then decrease your counter.
|
|
|
|
|
Do you have your users log on and log off? I'd like to get a feel of what your website is doing, so I can try to help you.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
try this maybe can help u
Regards,
Tomi
|
|
|
|
|
Hi.
For viewing error message in asp (ASP 3.0 Not ASP.Net) pages instead of a general message (500-Internal Server Error),
in IE7 In windows vista I isables "Show Friendly HTTP error messages" but now I see "An error occurred on the server when processing the URL. Please contact the system administrator"
But I'm Admin
Best wishes
|
|
|
|
|
You should be able to customize error pages. I think you need to do something like a file, for example. called 500.html and point the webserver to that file when it throws an error 500.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
I need to setup a custom 404 error on a new web host for a client. The host supports ASP .NET 1.1. The host don't want to configure IIS for 404 errors and wants me to use web.config to handle the errors.
I created a web.config file in a text editor and placed it into the root directory.
I then created another file named test.htm and also placed into the root directory of the website.
-------- web.config --------
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.web>
<customErrors defaultRedirect="/test.htm" mode="On">
<error statusCode="404" redirect="/test.htm" />
</customErrors>
</system.web>
</configuration>
----------------------------
--------- test.htm ---------
<HTML>
<HEAD><TITLE>Static</TITLE></HEAD>
<BODY>This is a static page</BODY>
</HTML>
----------------------------
If I enter: http://hostname/web.config
The test.htm file is served back by the web server.
If I enter: http://hostname/missing.htm
I get the standard 404 message, not my test.htm
These are the only two files that I added to site after the host created the web.
Any guidance as to what to try next? I did try changing the redirect from "/test.htm" to "test.htm", but the effect was the same.
Thank You
|
|
|
|
|
Contact the webhost, they should have a tech support department that can help you out. If they are incompetent, then that maybe bad...
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Paul, Thank you for the suggestion.
In the meantime, while I wait to hear back from the hosting company, does anyone have any suggestions as to why this doesn't work?
|
|
|
|
|
leapforward wrote: while I wait to hear back from the hosting company
How long is the wait?
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
It's the client's hosting company that purchases through a reseller agreement with the real hosting company. So communication is a challenge.
I did discover that the 404 works for any request that cannot be found that has a .aspx extension. But, I need to be able to handle many extensions including: (.htm, .html, .asp, .pdf, .doc). I also need to be able to handle the situation when there is no extension, such as: /corporate/clients
My guess is that they are going to configure IIS to use the page that I originally requested. unless anyone has ideas on how to easily make this work for all paths with or without file extensions.
Thanks Again...
|
|
|
|