by via .NET slave on 5/16/2007 8:04:00 PM
Some time ago, when I wrote the blog post importer for BlogEngine.NET, I wanted to be able to display different text in the ClickOnce application dependant on the user opening it directly from a web page. I did some digging and found out that ClickOnce supports query strings just like a website.
That made it possible to create a link similar to this:
BlogConverter.application?url=http://blog.madskristensen.dk/&username=my username
In your ClickOnce project, right-click the project file in Solution Explorer and click Properties. Select the Publish tab and press the Options… button. Here you need to check the Allow URL parameters to be passed to application checkbox and hit the OK button.
The next thing was to find out how to retrieve the values of the query strings, because a ClickOnce application does not have an HttpContext so there is no Context.Request.QueryString property.
Instead, you need to retrieve the query strings from the application deployment context. I used this handy method, which returns a NameValueCollection of all the query strings.
using System.Deployment.Application; using System.Web; using System.Collections.Specialized;
private NameValueCollection GetQueryStringParameters() { NameValueCollection col = new NameValueCollection();
if (ApplicationDeployment.IsNetworkDeployed) { string queryString = ApplicationDeployment.CurrentDeployment.ActivationUri.Query; col = HttpUtility.ParseQueryString(queryString); }
return col; }
It’s pretty easy if you know where to look.
Original Post: URL parameters in ClickOnce applications
The content of the postings is owned by the respective author. CSharpFeeds is not responsible for the contents of the postings. This site is automatically generated and cannot be reviewed for abusive content. If you find abusive content on CSharpFeeds, please contact us. Designated trademarks and brands are the property of their respective owners. All rights reserved.