I am developing a internal app in c# which calls one of the banking site. I need to enter curency in DDL, amount in textbox and neeed to find out the exchange rate.
here is the link which i need to use..
https://www.timesofmoney.com/remittance/secure/rmtExchRateCalculator.jsp?tab=US&sendercountry=US&sendercurrency=USD&uiId=TOML&partnerId=TOML
I used myWebClient.UploadValues(C#) but the site is returning some errors...can some one help me with this..
My Code:
string uriString= "https://www.timesofmoney.com/remittance/secure/rmtExchRateCalculator.jsp?tab=US&sendercountry=US&sendercurrency=USD&uiId=TOML&partnerId=TOML";
// Create a new WebClient instance.
WebClient myWebClient = new WebClient();
// Create a new NameValueCollection instance to hold some custom parameters to be posted to the URL.
NameValueCollection myNameValueCollection = new NameValueCollection();
// Add necessary parameter/value pairs to the name/value container.
myNameValueCollection.Add("selCountry", "United States");
myNameValueCollection.Add("rmtAmount", "100");
byte[] responseArray = myWebClient.UploadValues(uriString, myNameValueCollection);
Response.Write(Encoding.ASCII.GetString(responseArray));
The response I got from the site:
Inconvenience Regretted !
Please check your browser settings to enable you to use the site. You may be facing this problem due to old cookies and temporary internet files
Delete the temporary Internet files.
To delete the temporary Internet files, follow these steps:
Start Internet Explorer.
On the Tools menu, click Internet Options, and then click the General tab.
Under Temporary Internet files, click Delete Cookies.
Click OK when you are prompted to confirm the deletion.
Click Delete Files.
Click OK when you are prompted to confirm the deletion.
Under History, click Clear History.
Click Yes when you are prompted to delete your history of visited Web sites.
Click OK.
Close all open browsers and restart new browser again
It seems like the page requires cookies. Take a look here to see how to handle cookies with WebClient.
To debug your problem you can also install a header sniffing tool like Live HTTP Headers for Firefox or ieHTTPHeaders for Internet Explorer and try to send the same information via WebClient (same User Agent, Referrer etc.).
You can try www.coinmill.com. I used javascript to get the exchange rate/currency conversions of there site with no problems. Hope this helps
Related
Hi guys this is my follow up question and I think this is the real issue here. Click Here
Whenever I access the file using the directory browsing (eg. http://localhost/temp/1.pdf) it always render the old or previous PDF file even if I change the entire file with the same file name, example I have 1.pdf with some content then I delete this file on the directory then replace with new and different content and rename it to 1.pdf then when I access it using browser it always render the previous value not the new one that I replace. This only happens on IE and Opera browser. Please need help this is a production issue.
Edit:
I found something very strange, example i have this url for the location of the pdf file (eg. http://localhost/website/tempfolder/1.pdf) the first pdf that I generated will show then some part in my code I change the casing of some letter example 't', I change it to 'T' then the newly pdf shows but when I revert back to the old case expecting that it will show the new pdf but sad to say the first PDF file shows.
Your browser is probably caching the PDF files.
For IE, you can do a CTRL F5 to force it to reload from web server.
Or put a random query string in your URL
e.g. /temp/1.pdf?v=1, /temp/1.pdf?v=2
Assuming you server is IIS, permanent solution is to configure HTTP response headers.
Go to IIS manager
Navigate to your folder
Click "HTTP Response Headers" in Features View
Right-button click/select "Set Common Headers"
Check "Expire Web Content" and select "Immediately".
I am creating an Add-in for Outlook 2010. Once the button is clicked, the email and subject will be saved to database (this is fine) and will also redirect to a URL. Could you please tell me how to do the URL redirection for VSTO? Not sure if that is possible. Thanks!
You can use Process.Start() to open the URL in the user's default web browser as follows:
Process.Start("explorer.exe", #"http://www.google.com");
or more simply (as you found out):
Process.Start(#"http://www.google.com");
To be clear, you're not redirecting, just simply browsing to the URL in a new window.
If it's a outlook form region you use, you could use the Navigate2 of the SHDocVw.WebBrowser
I am not sure if you wanted to open a new url in the default web browser.
I'm sorry if this subject has already been answered, but I couldn't find what I needed (yet).
I'm working on a program that downloads files from university websites that use the same infrastructure. It's an open source project which I'm trying to support in my free time
(hosted in goodle code: http://code.google.com/p/highlearner/)
Until now we used GET and POST requests to login into the right page and download stuff. But the universities keep changing their websites and every little change requires teaking in Highlearner, which requires a new version, auto-updating all users, etc. Also, every university has its own login page, requiring me to tailor a login sequences..
So I'm looking for a more robust solution. Instead of manually redirecting and setting the HTTP parameters. Is there some kind of mini browser that supports with HTML + Javascript? No GUI is needed, I just need the engine.
This way, I will simply need to fill out the form parameters and let the browser do the work.
Thanks,
Nitay
You could try to automate the process with WatiN library . It allows you to click buttons, submit forms, etc.
using (var ie = new IE(loginUrl))
{
if (ie.TextField("username").Exists
&& ie.TextField("password").Exists)
{
ie.TextField("username").Value = "username";
ie.TextField("password").Value = "password";
ie.Button(Find.ByName("submit")).Click();
}
}
Conditions:
The files must be opened outside of the window that the link to them is in.
I have tried href, but when I give it an intranet link it only opens correctly if I leave out target="_blank"; if I put that in, the new window that opens doesn't receive the full link if there is a pound sign in the filepath... a direct link to the intranet address \a\b\c#c.txt would be fine with me; there is no concern about security, but I can't seem to get that to happen in a new window. It seems like this is happening when I don't create a new window, but I can't utilize the same window to open the links.
Any ideas?
It's a bit of a hack but try changing the links to href="#" onclick="window.open('http://' + escape(restofurl))"
Even if you can get the link to work, the user accessing it may or may not have rights to see that machine.
What I do in cases where I have to link to other files on other server, is link to a generic handler(.ashx file) that does impersonation of user that does have rights, or impersonates the logged-in user. The handler then reads the contents of the file and streams it to the user.
Have you tried streaming the file contents to the browser?
I have a web page (asp.net) that compiles a package then redirects the user to the download file via javascript (window.location = ....). This is accompanied by a hard link on the page in case the redirect doesn't work - emulating the download process on many popular sites. When the IE information bar appears at the top due to restricted security settings, and a user clicks on it to download the file, it redirects the user to the page, not the download file, which refreshes the page and removes the hard link.
What is the information bar doing here? Shouldn't it send the user to the location of the redirect? Am I setting something wrong in the headers of the download response, or doing something else wrong to send the file in the first place?
C# Code:
m_context.Response.Buffer = false;
m_context.Response.ContentType = "application/zip";
m_context.Response.AddHeader("Content-Length", fs.Length.ToString());
m_context.Response.AddHeader("Content-Disposition", string.Format("attachment; filename={0}_{1}.zip", downloadPrefix, DateTime.Now.ToString("yyyy-MM-dd_HH-mm")));
//send the file
When a user agrees to download a file using the IE Information Bar, IE reloads the current page, not the page the file the user is trying to download. The difference is that, once the page is reloaded, IE will allow the download script to go through without prompting the user. I'm not sure what the thinking is on this from a design standpoint, but that's how it seems work.