Home>

The asp.net iis registration tool (aspnet_regiis.exe) can be used to easily update the script mapping of asp.net applications,Make it point to the asp.net isapi version associated with the tool.

More details about the asp.net iis registration tool,Please refer to msdn.

On the console we can use the following command to modify the asp.net version of a virtual directory:

aspnet_iis.exe --s path

We know how to modify the version of a virtual directory,The question now is how to implement it using a program.

The following code is based.Net framework 2.0 compiles in windows xp sp2:

//Create a virtual directory
directoryentry dirroot=new directoryentry ("iis://localhost/w3svc/1/root");
directoryentries dirs=dirroot.children;
directoryentry virtualdir=dirs.add ("virtualchange", dirroot.schemaclassname);
object [] objs=new object [] {true};
virtualdir.invoke ("appcreate", objs);
virtualdir.properties ["appfriendlyname"] [0]="virtualchange";
virtualdir.properties ["path"]. value="c:\\ virtualchange";
virtualdir.commitchanges ();
//Start the aspnet_iis.exe program
string filename=environment.getenvironmentvariable ("windir") [email protected]"\ microsoft.net \ framework \ v1.1.4322 \ aspnet_regiis.exe";
processstartinfo startinfo=new processstartinfo (filename);
//Handle the directory path
string path=virtualdir.path.toupper ();
int index=path.indexof ("w3svc");
path=path.remove (0, index);
//Start the aspnet_iis.exe program and refresh the textbook mapping
startinfo.arguments="-s" + path;
startinfo.windowstyle=processwindowstyle.hidden;
startinfo.useshellexecute=false;
startinfo.createnowindow=true;
startinfo.redirectstandardoutput=true;
startinfo.redirectstandarderror=true;
process process=new process ();
process.startinfo=startinfo;
process.start ();
process.waitforexit ();
string errors=process.standarderror.readtoend ();
if (errors!=string.empty)
  throw new exception (errors);
console.writeline (process.standardoutput.readtoend ());
c
  • Previous Recommend 10 awesome jQuery effects code
  • Next Two ways to determine the type prefix of CSS browsers with JavaScript