开发者

How to specify a port for the ASP.NET Configuration Site?

Is ther开发者_JAVA百科e any way to specify a permanent port for ASP.NET Configuration site (Web Site Administration Tool)?

I need to add a link to the ASP.NET Configuration site, but I can't due to the port changing each time it starts.

How to specify a port for the ASP.NET Configuration Site?


Its the port for ASP.NET Development server

http://msdn.microsoft.com/en-us/library/ms178109.aspx


I'm not sure that you can.

The Web Site Administration Tool isn't really meant to be "linked" to as such, it's a fairly powerful, unsecured application, that's only really meant to be run by a developer/admin.

The "Considerations" section of the documentation explain why:

The following sections provide some considerations for working with the Web Site Administration Tool.

Restarting the Application When Saving

Most changes to configuration settings that you make in the Web Site Administration Tool take effect immediately. This requires the Web site to which the change applies to be restarted. Because this will cause currently active sessions in the Web site to be lost, you should make configuration changes to a staged or development version of the Web site before publishing these changes to the production server.

Saving Your Settings

Most changes to configuration settings that you make in the Web Site Administration Tool take effect immediately. For settings for which the Web Site Administration Tool interface has a dedicated Save button, leaving the Web Site Administration Tool idle or allowing the Web Site Administration Tool to time out before you click Save will cause your configuration settings changes to be lost.

Time Out

As a security measure, the Web Site Administration Tool times out after a period of inactivity. Any settings that did not take effect immediately and were not saved will be lost. If the Web Site Administration Tool has timed out, close your browser, and then reopen the Web Site Administration Tool in a new window.

The Web Site Administration Tool manages only some of the configuration settings that are available to the Web site. Many other settings require direct modification of configuration files either manually, by using the MMC Snap-In for ASP.NET, or programmatically, by using the ASP.NET Configuration API.

From that you can see that this isn't something that's intended to be kept around.

That said, with a little bit of hacking around, you could probably shoot yourself in the foot achieve what you're after:

If you right click on the ASP.NET Development server task tray item for the admin tool, and select "Show Details", you can see that the virtual directory that the tool runs under is mapped to (something like):

C:\Windows\Microsoft.NET\Framework\v4.0.30319\asp.netwebadminfiles\

If you were to create (and secure) a virtual directory on your application mapped to that path, you might well be able to get this all up and running as you want.


As pseudocoder points out in his comment below, while going down the Virtual Directory route does "work", there are some limitations to the tool that, coupled with the security issues mean that you probably wouldn't want to use it going forward.

If you were to stick with the Development Server option, the tool won't respond to non-local requests, and once you've deployed the site to a proper web server (IIS) for users to access the Admin site won't be running anyway.

It would probably be better if you could explain why you want to use this permanently so we can advise you on some better options - for example the Membership, Profile and Role providers both provide nice APIs for managing user details that can be easily built into a custom admin area.


Tricky one, however I think to get this working correctly, you're going to have to spend some time doing something, and it's probably better for you in the long run to spend that time doing the right thing rather than hacking in the wrong option.

The Development server can be started from a command line, using a commands along the lines of:

call "C:\Program Files\Microsoft Visual Studio 9.0\vc\vcvarsall.bat"
"C:\Program Files\Common Files\Microsoft Shared\DevServer\9.0\WebDev.WebServer.exe" /port:3900 /path:"PATHSITE" /vpath:"PathSite"
  1. The first line sets up the CMD instance to use the variables and path settings needed to run most of the Dev tooling
  2. You'll want to change the path to the DevServer as appropriate for your environment (mine's in \10.0\ for example, and has a 2.0 and 4.0 version).

Armed with this information, you could do something along the lines of:

  • Add a link to your site to a page called /StartAdmin.aspx or similar.
  • In that page, you would then need to have the logic to:
    • Check through the running processes for the instance of the DevServer that was previously used to host the Admin site.
    • Close that process down.
    • Spool up another instance of the DevServer with a known port, pointing to the path for the WebAdmin Site.
    • Redirect the user to this new site.

All of which is possible, but it's not trivial, and you'll find you'll need to be doing odd things with the process your starting, and you'll need to be very careful you don't shut down the instance of the DevServer that's actually running your site by mistake.

However, this would probably take as long as it would to knock up a quick set of user admin screens, and you'd learn something more useful along the way*

* Which isn't to say that learning how to start and leave running a process isn't useful, it's more to say that I'm guessing its not what you're supposed to be learning at the moment, and you should probably be focusing on that ;)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜