1
//-----------------------------------------------------------------------
2 // <copyright file="AspNetHost.cs" company="Andrew Arnott">
3 // Copyright (c) Andrew Arnott. All rights reserved.
5 //-----------------------------------------------------------------------
7 namespace DotNetOpenAuth
.Test
.Hosting
{
11 using System
.Threading
;
13 using System
.Web
.Hosting
;
14 using DotNetOpenAuth
.Messaging
;
15 using DotNetOpenAuth
.Test
.OpenId
;
18 /// Hosts a 'portable' version of the OpenIdProvider for testing itself and the
19 /// RelyingParty against it.
21 internal class AspNetHost
: MarshalByRefObject
{
22 private HttpHost httpHost
;
25 httpHost
= HttpHost
.CreateHost(this);
26 ////if (!UntrustedWebRequestHandler.WhitelistHosts.Contains("localhost"))
27 //// UntrustedWebRequestHandler.WhitelistHosts.Add("localhost");
31 get { return httpHost.BaseUri; }
34 public static AspNetHost
CreateHost(string webDirectory
) {
35 AspNetHost host
= (AspNetHost
)ApplicationHost
.
36 CreateApplicationHost(typeof(AspNetHost
), "/", webDirectory
);
40 public string ProcessRequest(string url
) {
41 return httpHost
.ProcessRequest(url
);
44 public string ProcessRequest(string url
, string body
) {
45 return httpHost
.ProcessRequest(url
, body
);
48 public void BeginProcessRequest(HttpListenerContext context
) {
49 ThreadPool
.QueueUserWorkItem(state
=> { ProcessRequest(context); }
);
52 public void ProcessRequest(HttpListenerContext context
) {
54 using (TextWriter tw
= new StreamWriter(context
.Response
.OutputStream
)) {
55 HttpRuntime
.ProcessRequest(new TestingWorkerRequest(context
, tw
));
57 } catch (Exception ex
) {
58 Logger
.Error("Exception in AspNetHost", ex
);
63 public void CloseHttp() {