URL redirect + VSTO - c#

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.

Related

Save SSRS report as PDF in .net Winforms app without rendering report [duplicate]

I have an SSRS2016 Report that I'm able to connect to in the browser:
http://vmbksa69901mcz/reports_ssrs1d/report/DAS/CDO_Suite/AccruedInterestRpt
But I want to be able to export to pdf by the url. This article states that this is possible:
https://learn.microsoft.com/en-us/sql/reporting-services/export-a-report-using-url-access
So, when I try to put in this url:
http://vmbksa69901mcz/reports_ssrs1d?/DAS/CDO_Suite/AccruedInterestRpt&rs:Format=PDF
It does not work.. It just brings me to the home page of the SSRS Site, and changes the url to:
http://vmbksa69901mcz/reports_ssrs1d/browse/
I don't see what I'm doing wrong here.
When you use a URL to pass commands you need to use the Web Service URL reportserver path in the URL not the web portals URL.
If you run the Reporting Services Configuration Manager and look under "Web Service URL" you see a different address.
By default the web portal (SSRS home page as you called it) will be at http://myServer/Reports
But the Web Service URL by default is
http://myServer/Reportserver
Adding on to #Alan's answer, my report was for exporting to excel :
A report with url :
http://myservername/Reports/report/myserverSSRSUpgrade/PCM%20Allocation%20Report?DateFrom=04%2F01%2F2018&DateTo=04%2F30%2F2018&ParentID=46416&rs:Format=EXCELOPENXML
gets converted to
http://myservername/ReportServer?%2fmyserverSSRSUpgrade%2fPCM+Allocation+Report&DateFrom=04%2F01%2F2018&DateTo=04%2F30%2F2018&ParentID=46416&rs:Command=Render&rs:Format=EXCELOPENXML
Have a close look at the placement of ? character in both the query strings.

Unable to download file (page url same as download url)

I'm trying to download a zip file (that is normally accessed/downloaded by pressing a button on a web page) using C#.
Normally the file is downloaded by selecting "Data Export" and then clicking the "SEARCH" button at this URL:
http://insynsok.fi.se/SearchPage.aspx?reporttype=0&culture=en-GB&fromdate=2016-05-30&tomdate=2016-06-03
If trigger the download manually on the webpage and then copy the download url from the 'Downloads' view of chrome or firefox I get the exact same URL as above. When I paste that in a browser window I will not trigger the download, instead the above page will be loaded and I have to trigger the download manually in the same way as in the first place.
I've also tried using the network tab of the inspector to copy the request header of the request that is triggered when clicking the "SEARCH" button, but that URL is also the same as the one above.
Trying with C# I get the same result, the page itself is downloaded. My code looks as follows:
using (var client = new WebClient())
{
client.DownloadFile("http://insynsok.fi.se/SearchPage.aspx?reporttype=0&culture=sv-SE&fromdate=2016-05-30&tomdate=2016-06-03", "zipfile.zip");
}
My guess is that my code is correct, but how do I get the correct URL to be able to download the file directly?
ASP.net inserts a bunch of crap into the the page to make things like this particularly hard. (Validation tokens, form tokens, etc).
Your best bet is to use a python library called Mechanize, or if you want to stick to C# you can use Selenium or C# WebBrowser. This will fully automate visiting the page (you can render the C# WebBrowser invisible), then just click the button to trigger the download programatically.

How to redirect/transfer from .ashx file without opening new tab?

Im making some changes to a website i haven't developed before. All links opened via a go.ashx page to verify that it was used by a logged in user.. When the .ashx verifies the user ut openes the URL via context.Response.Redirect(url, true); This openes a new tab, how do i make it just a redirect without the new tab?
I think the problem can be with the links
anchor text
or even
anchor text
It should be like
anchor text
the target should be self. If you can post your link then it can be helpful.

How to submit a form from c#

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

IE Information Bar, download file...how do I code for this?

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.

Categories