RE: programatically changing the .net version of virtual directory



Thanks for the response, but I need to do this programatically from withing
my aspx page. This tool internally uses aspnet_regiis, and I have explained
the problem of using it in my first post.


"WoodenSWord" wrote:

You can check this site out:

http://www.denisbauer.com/NETTools/ASPNETVersionSwitcher.aspx

"Rak" wrote:

I am looking for a way to programatically change the .net version of the
virtual directory that I am creating within a aspx page.
As part of creating a new customer in my asp.net 2 application, it
automatically creates a virtual directory and configures it. I am using the
DirectoryServices.DirectoryEntry class in C# to do this. I am unable to set
the .Net version of the virtual directory from 1.1 to version 2. All searches
led me to the aspnet_regiis.exe. I tried 2 different solutions:-
----------------------------------------------------------------------
1. Call aspnet_regiis.exe -s W3SVC/1/root/vdirname from my aspx page after
creating the virtual directory. It fails because the process is running as
'NETWORK SERVICE' user who does not have enough permission to do these. When
I changed the identity of the Application Pool from 'Network Service' to
'Local System', I could run successfully change the version using
aspnet_regiis.exe

//Code in aspx page
string strFrameworkVersion =
ConfigurationManager.AppSettings["frameworkVersion"];
string winPath = Environment.GetEnvironmentVariable("windir");
string fullPath = winPath + @"\Microsoft.NET\Framework\v" +
strFrameworkVersion + @"\aspnet_regiis.exe";
string args = " -s " + "W3SVC/1/root/" + nameDirectory;

ProcessStartInfo startInfo = new ProcessStartInfo(fullPath);
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.UseShellExecute = false;
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardError = true;

System.Diagnostics.Process process = new System.Diagnostics.Process();
startInfo.Arguments = args;
process.StartInfo = startInfo;
process.Start();
process.WaitForExit();

---------------------------------------------------------------
2. I tried to modify the scriptmap programatically to match what
aspnet_regiis.exe does, i.e. changes the path to the right version of .NET.
But that made no difference. In fact, after running this code, the virtual
directory had no version of .NET selected.

PropertyValueCollection vals = siteVDir.Properties["ScriptMaps"];
ArrayList objScriptMaps = new ArrayList();
string frameworkVersion =
ConfigurationManager.AppSettings["frameworkVersion"];

foreach (string val in vals)
{
if (val.Contains("Framework"))
{
string version = val.Substring(val.IndexOf("Framework")
+ 10, 9);
if(version != frameworkVersion)
{
objScriptMaps.Add( val.Replace(version,
frameworkVersion));
}
}
else
{
objScriptMaps.Add(val);
}
}

siteVDir.Properties["ScriptMaps"].Value =
objScriptMaps.ToArray();
siteVDir.CommitChanges();
------------------------------------------

What is the most appropriate way to change the .NET version of the created
virtual directory, programatically from within as aspx page?

Thanks
Rakesh
.



Relevant Pages

  • Framework conflict??
    ... applicaction and I try to open an aspx page, ... can be caused by a virtual directory not being configured as an application ... application directory property in site properties, ...
    (microsoft.public.dotnet.framework.aspnet)
  • programatically changing the .net version of virtual directory
    ... virtual directory that I am creating within a aspx page. ... automatically creates a virtual directory and configures it. ... string strFrameworkVersion = ...
    (microsoft.public.dotnet.framework.aspnet)
  • RE: programatically changing the .net version of virtual directory
    ... virtual directory that I am creating within a aspx page. ... automatically creates a virtual directory and configures it. ... string strFrameworkVersion = ...
    (microsoft.public.dotnet.framework.aspnet)
  • Verify if file exists on network shared HELP
    ... I just configure this path as a virtual directory to get access and show it in one ASPX page. ... Regards, ... MCSD Henry Miranda ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: Hosting On IIS
    ... > I create a virtual directory named Test and copy these dlls in this ... > directory to host remote object on IIS. ... > string GetCurrentSong(); ... > namespace RemotingServer ...
    (microsoft.public.dotnet.framework.remoting)