diff --git a/src/Microsoft.AspNet.Http.Core/BufferingHelper.cs b/src/Microsoft.AspNet.Http.Core/BufferingHelper.cs index 58ef9c509e..32dde60d46 100644 --- a/src/Microsoft.AspNet.Http.Core/BufferingHelper.cs +++ b/src/Microsoft.AspNet.Http.Core/BufferingHelper.cs @@ -3,7 +3,6 @@ using System; using System.IO; -using Microsoft.AspNet.Http; using Microsoft.AspNet.WebUtilities; namespace Microsoft.AspNet.Http.Core @@ -16,11 +15,9 @@ namespace Microsoft.AspNet.Http.Core { get { - var temp = Environment.GetEnvironmentVariable("ASPNET_TEMP"); - if (string.IsNullOrEmpty(temp)) - { - temp = Environment.GetEnvironmentVariable("TEMP"); - } + // Look for folders in the following order. + var temp = Environment.GetEnvironmentVariable("ASPNET_TEMP") ?? // ASPNET_TEMP - User set temporary location. + Path.GetTempPath(); // Fall back. if (!Directory.Exists(temp)) { diff --git a/test/Microsoft.AspNet.Http.Core.Tests/BufferingHelperTests.cs b/test/Microsoft.AspNet.Http.Core.Tests/BufferingHelperTests.cs new file mode 100644 index 0000000000..362849193c --- /dev/null +++ b/test/Microsoft.AspNet.Http.Core.Tests/BufferingHelperTests.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.IO; +using Xunit; + +namespace Microsoft.AspNet.Http.Core.Tests +{ + public class BufferingHelperTests + { + [Fact] + public void GetTempDirectory_Returns_Valid_Location() + { + var tempDirectory = BufferingHelper.TempDirectory; + Assert.NotNull(tempDirectory); + Assert.True(Directory.Exists(tempDirectory)); + } + } +} \ No newline at end of file