Custom IApplicationHost

M

Mark Carrington

Hi,

I have an application which uses the
ApplicationHost.CreateApplicationHost API to embed ASP.NET. My problem
is that I need to be able to duplicate the virtual directory type
structure supported by IIS, e.g.

URL / maps to c:\mysite
URL /dir1 maps to c:\mysite\dir1

but

URL /dir2 maps to c:\some\other\dir

To do this, it appears I need to create a custom implementation of the
System.Web.Hosting.IApplicationHost interface, but this is internal. The
docs for .NET 3 list this as public
(http://msdn2.microsoft.com/en-us/library/system.web.hosting.iapplicationhost.aspx),
but I cannot find a public definition of it after downloading the .NET 3
redist package.

Is there some way to get access to this interface to allow me to write
my own implementation?

Thanks,

Mark
 
W

Walter Wang [MSFT]

Hi Mark,

Sorry about the MSDN documentation, it's not correct here: the interface is
internal and it's not changed by .NET 3.0 runtime; 3.0 runtime only addes
some assemblies, not changed existing .NET 2.0 library.

For your question about supporting multiple virtual directory using
ApplicationHost, I will do some additional research and get back to you.
Thank you for your patience and understanding.


Sincerely,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
M

Mark Carrington

Walter,
Sorry about the MSDN documentation, it's not correct here: the interface is
internal and it's not changed by .NET 3.0 runtime; 3.0 runtime only addes
some assemblies, not changed existing .NET 2.0 library.

That's what I thought - thanks for the confirmation.
For your question about supporting multiple virtual directory using
ApplicationHost, I will do some additional research and get back to you.
Thank you for your patience and understanding.

Thanks - I'd be grateful for any information you can get on this.

Mark
 
W

Walter Wang [MSFT]

Hi Mark,

To support multiple virtual directory, you must have your own configuration
and use different physical path for each request. I've found that
http://www.systemex.net/CassiniEx/ may be a good reference for you. It's
based on Cassini and has support for multiple web sites and applications in
a single instance. (Note this is a third party implementation)

Hope this helps.


Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
M

Mark Carrington

Walter,
To support multiple virtual directory, you must have your own configuration
and use different physical path for each request. I've found that
http://www.systemex.net/CassiniEx/ may be a good reference for you. It's
based on Cassini and has support for multiple web sites and applications in
a single instance. (Note this is a third party implementation)

I've seen CassiniEx, and this seems to work fine for each main request.
The problem comes if you try to do Request.MapPath during a request.

In the CassiniEx model, the HttpWorkerRequest.GetFilePathTranslated
method is overridden to return the correct physical path to the
oringally requested file, e.g. Default.aspx. If that page tries to use
Request.MapPath within its code, that mapping will not use any of the
additional virtual paths.

I have noticed the MapPath method within HttpWorkerRequest, but that
never seems to be called.

Mark
 
W

Walter Wang [MSFT]

Hi Mark,

I'm still reading the source code of CassiniEx; do you mean that the
AspNetWorkerRequest.MapPath() isn't called? Based on my research, one
possible fix is you need to create a constructor like this:

public AspNetWorkerRequest(string page, string query, TextWriter output)
: base(page, query, output)
{
}

SimpleWorkerRequest's documentation for this constructor:

Initializes a new instance of the System.Web.Hosting.SimpleWorkerRequest
class when the target application domain has been created using the
System.Web.Hosting.ApplicationHost.CreateApplicationHost(System.Type,System.
String,System.String) method.


I'm not sure if this would help since I haven't a chance to verify. Would
you please try this on your side and let me know the result? Also, it would
be great if you could send me some reproducible code to test the behavior
more quickly. Thanks.


Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
M

Mark Carrington

Walter,
I'm still reading the source code of CassiniEx; do you mean that the
AspNetWorkerRequest.MapPath() isn't called?

Yes, that appears to be the case. If that was called my problem would be
solved.
Based on my research, one
possible fix is you need to create a constructor like this:

public AspNetWorkerRequest(string page, string query, TextWriter output)
: base(page, query, output)
{
}

SimpleWorkerRequest's documentation for this constructor:

Initializes a new instance of the System.Web.Hosting.SimpleWorkerRequest
class when the target application domain has been created using the
System.Web.Hosting.ApplicationHost.CreateApplicationHost(System.Type,System.
String,System.String) method.


I'm not sure if this would help since I haven't a chance to verify. Would
you please try this on your side and let me know the result?

This was the basis for my first attempt, which didn't work.
Also, it would
be great if you could send me some reproducible code to test the behavior
more quickly. Thanks.

I'll try to put a simple test app together shortly.

Thanks,

Mark
 
W

Walter Wang [MSFT]

Hi Mark,

Let me know if it's difficult to create a simpler reproducible project on
your side.

Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
W

Walter Wang [MSFT]

Hi Mark,

Thanks for the code. I've been able to reproduce the issue on my side.

Furthermore, this looks like an issue in ASP.NET 2.0 since it's working
correctly in ASP.NET 1.1.

I'm currently confirming the behavior with product team. I'll keep you
posted. Thank you again for the feedback!

Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
M

Mark Carrington

Walter,
Thanks for the code. I've been able to reproduce the issue on my side.

Furthermore, this looks like an issue in ASP.NET 2.0 since it's working
correctly in ASP.NET 1.1.

I'm currently confirming the behavior with product team. I'll keep you
posted. Thank you again for the feedback!

Thanks for the update, it's greatly appreciated. Please let me know when
there is a workaround or fix available.

Mark
 
W

Walter Wang [MSFT]

Hi Mark,

I got some confirmation of the issue from product team, they're currently
still looking into this.

Please email me so that I can update you promptly whenever I get any
further update on it. Thanks.


Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 

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

Top