can I progarmatically register asp.net to IIS

C

chandan

Hi,
I am using aspnet_regiss.exe utility from command prompt to register
asp.net to IIS. But my requirement is to do it programmatically so
that client need not worry about this registration. Can we do this
programmatically??

Thanks
Chandan
 
D

David R. Longnecker

Chandan-

You could create a simple command file that the client (or you) run on installation
(or build it into your deployment package).

%windir%\Microsoft.Net\Framework\v2.0.50727\aspnet_regiis.exe -i

I suppose you could also do something using the System.Diagnostics.Process
class and create a little Console executable, but this might a bit of overkill.
Remember, simple (hence, a command file), is good. :)

If you want a console file to ask for input, etc or have other tasks, here's
a quick example using your aspnet_regiis.exe file:

// Create a new Process object.
Process registerProcess = new Process();

// Assign the aspnet_regiis.exe file to the process.
registerProcess.StartInfo.FileName =
System.Environment.GetEnvironmentVariable("windir") +
@"\Microsoft.Net\Framework\v2.0.50727\aspnet_regiis.exe";

// Pass along the -i parameter (install)
registerProcess.StartInfo.Arguments = @"-i";

// Simply return the output to the same calling command window.
registerProcess.StartInfo.RedirectStandardOutput = false;
registerProcess.StartInfo.CreateNoWindow = false;
registerProcess.StartInfo.UseShellExecute = false;

// Start the process.
try
{
// Start the process.
registerProcess.Start();
}
catch (Exception ex)
{
throw;
}
finally
{
registerProcess.Dispose();
}

Hope this helps!

-dl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top