Skip to content

Commit d49b219

Browse files
committed
Url.Authority instead of host + port.
1 parent fddee27 commit d49b219

File tree

3 files changed

+19
-14
lines changed

3 files changed

+19
-14
lines changed

DevTrends.MvcDonutCaching.Demo/Controllers/LoadTestController.cs

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
using System;
2-
using System;
3-
using System.Collections.Generic;
4-
using System.Collections.Generic;
5-
using System.Configuration;
2+
using System.Diagnostics;
63
using System.IO;
7-
using System.Linq;
8-
using System.Linq;
94
using System.Net;
105
using System.Net.Cache;
116
using System.Threading;
127
using System.Threading.Tasks;
13-
using System.Web;
148
using System.Web.Mvc;
159

1610
namespace DevTrends.MvcDonutCaching.Demo.Controllers
@@ -24,7 +18,15 @@ public ActionResult ApplyLoad()
2418
long requestsMade = 0;
2519

2620
var relativeUrl = Url.Action("LargeOutPutRootAction");
27-
var uri = string.Format("{0}://{1}:{2}{3}", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, relativeUrl);
21+
22+
Debug.Assert(Request.Url != null, "Request.Url != null");
23+
24+
var uri = string.Format(
25+
"{0}://{1}{2}",
26+
Request.Url.Scheme,
27+
Request.Url.Authority,
28+
relativeUrl
29+
);
2830

2931
var cancellationTokenSource = new CancellationTokenSource();
3032
var parallelOptions = new ParallelOptions
@@ -53,10 +55,14 @@ public ActionResult ApplyLoad()
5355

5456
using (var response = webRequest.GetResponse())
5557
using (var stream = response.GetResponseStream())
56-
using (var reader = new StreamReader(stream))
5758
{
58-
reader.ReadToEnd();
59-
Interlocked.Increment(ref requestsMade);
59+
Debug.Assert(stream != null, "stream != null");
60+
61+
using (var reader = new StreamReader(stream))
62+
{
63+
reader.ReadToEnd();
64+
Interlocked.Increment(ref requestsMade);
65+
}
6066
}
6167
});
6268
}

DevTrends.MvcDonutCaching.Demo/Global.asax.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace DevTrends.MvcDonutCaching.Demo
99
{
10-
public class MvcApplication : System.Web.HttpApplication
10+
public class MvcApplication : HttpApplication
1111
{
1212
public IContainer Container
1313
{
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
@model long
22

3-
43
<h2>Load Test Results</h2>
5-
<h2>Excecuted @Model requests</h2>
4+
<h3>Executed @Model requests</h3>

0 commit comments

Comments
 (0)