I have been involve in making our application web enable application for last 2 weeks and now a new requirement came to pass a parameter via the installation back to the application, i did a search on Google nothing much came out so i have post what i did so some one could benefit from it
1. go to project properties -> Publish
2. click on options and check "allow parameters to be pass to the url"
3. use this code snippet extract the parameter value,
4. eg http://www.hostname.com/sample.application?parameter=test
private static string parseParameters()
{
if (ApplicationDeployment.IsNetworkDeployed)
{
string[] activationData = AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData;
if (activationData != null)
{
Uri url = new Uri(activationData[0]);
Regex fileRegex = new Regex(@"^\?parameter=(?<1>[^&]*)$",
RegexOptions.Singleline);
Match fileMatch = fileRegex.Match(Uri.UnescapeDataString(url.Query));
if (fileMatch.Success)
return fileMatch.Groups[1].Value;
}
}
else
{
return null;
}
}
Monday, July 16, 2007
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment