Skip to content

Commit b97fc3f

Browse files
committed
Fixes for nested sites and prepare for version for release
1 parent 46827ee commit b97fc3f

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

WebFormsDocumentViewer.Tests/DocumentViewerTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public void TempDirectoryPath_When_PathIsEmpty_Then_TempFolderIsSet()
1616
{
1717
TempDirectoryPath = ""
1818
};
19-
Assert.That(documentViewer.TempDirectoryPath, Is.EqualTo("Temp"));
19+
Assert.That(documentViewer.TempDirectoryPath, Is.EqualTo("~/Temp"));
2020
}
2121

2222
[Test]
@@ -26,7 +26,7 @@ public void BuildControl_When_ExtensionIsNotSupported_Then_DocumentIsNotDisplaye
2626
{
2727
FilePath = ""
2828
};
29-
Assert.That(documentViewer.BuildControl("", "", "", "", "").ToString(), Is.EqualTo(new StringBuilder("Cannot display document viewer").ToString()));
29+
Assert.That(documentViewer.BuildControl("", "", "", "", "", "").ToString(), Is.EqualTo(new StringBuilder("Cannot display document viewer").ToString()));
3030
}
3131

3232
[Test]
@@ -36,7 +36,7 @@ public void BuildControl_When_PdfJsIsUsed_Then_FilePathIsSetAccordingly()
3636
{
3737
PdfRenderer = PdfRenderers.PdfJs
3838
};
39-
Assert.That(documentViewer.BuildControl("", "sample.pdf", "", "", "").ToString().Contains("/Scripts/pdf.js/web/viewer.html?file=../../../"));
39+
Assert.That(documentViewer.BuildControl("", "sample.pdf", "", "", "", "").ToString().Contains("Scripts/pdf.js/web/viewer.html?file="));
4040
}
4141

4242
[Test]
@@ -47,7 +47,7 @@ public void BuildControl_When_NoErrorsOccur_Then_IFrameIsSetUp()
4747
Width = Unit.Pixel(500),
4848
Height = Unit.Pixel(500)
4949
};
50-
Assert.That(documentViewer.BuildControl("", "sample.pdf", "", "", "").ToString(), Is.EqualTo("<iframe src=/sample.pdf width=500px height=500px></iframe>"));
50+
Assert.That(documentViewer.BuildControl("", "sample.pdf", "", "", "", "").ToString(), Is.EqualTo("<iframe src=/sample.pdf width=500px height=500px></iframe>"));
5151
}
5252

5353
[Test]
@@ -59,7 +59,7 @@ public void BuildControl_When_FileCannotBeConverted_Then_DocumentIsNotDisplayed(
5959
FilePath = "sample.pptx",
6060
TempDirectoryPath = "TmpFolder"
6161
};
62-
Assert.That(documentViewer.BuildControl("", "sample.pptx", "", "", "").ToString(), Is.EqualTo(new StringBuilder("Cannot display document viewer").ToString()));
62+
Assert.That(documentViewer.BuildControl("", "sample.pptx", "", "", "", "").ToString(), Is.EqualTo(new StringBuilder("Cannot display document viewer").ToString()));
6363
}
6464

6565
[Test]

WebFormsDocumentViewer/DocumentViewer.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public string TempDirectoryPath
4343
{
4444
get
4545
{
46-
return string.IsNullOrEmpty(tempDirectoryPath) ? "Temp" : tempDirectoryPath;
46+
return string.IsNullOrEmpty(tempDirectoryPath) ? "~/Temp" : tempDirectoryPath;
4747
}
4848
set
4949
{
@@ -72,7 +72,7 @@ public override void RenderControl(HtmlTextWriter writer)
7272
try
7373
{
7474
writer.Write(BuildControl(HttpContext.Current.Server.MapPath(FilePath), ResolveUrl(FilePath), HttpContext.Current.Server.MapPath(TempDirectoryPath),
75-
ResolveUrl(TempDirectoryPath), HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + ResolveUrl("~/")).ToString());
75+
ResolveUrl(TempDirectoryPath), HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority), ResolveUrl("~/")).ToString());
7676
}
7777
catch
7878
{
@@ -82,7 +82,7 @@ public override void RenderControl(HtmlTextWriter writer)
8282
}
8383

8484
public StringBuilder BuildControl(string filePhysicalPath, string fileVirtualPath, string tempDirectoryPhysicalPath,
85-
string tempDirectoryVirtualPath, string applicationRootUrl)
85+
string tempDirectoryVirtualPath, string appDomain, string appRootUrl)
8686
{
8787
try
8888
{
@@ -100,9 +100,9 @@ public StringBuilder BuildControl(string filePhysicalPath, string fileVirtualPat
100100
}
101101

102102
if (PdfRenderer == PdfRenderers.PdfJs && Enum.IsDefined(typeof(PdfJsSupportedExtensions), extension.ToString()))
103-
frameSource = string.Format("{0}/Scripts/pdf.js/web/viewer.html?file=../../../{1}", applicationRootUrl, frameSource);
103+
frameSource = string.Format("{0}{1}Scripts/pdf.js/web/viewer.html?file={0}{2}", appDomain, appRootUrl, frameSource);
104104
else
105-
frameSource = string.Format("{0}/{1}", applicationRootUrl, frameSource);
105+
frameSource = string.Format("{0}/{1}", appDomain, frameSource);
106106

107107
StringBuilder sb = new StringBuilder();
108108
sb.Append("<iframe src=" + frameSource + " ");

WebFormsDocumentViewer/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.0.8.0")]
36-
[assembly: AssemblyFileVersion("1.0.8.0")]
35+
[assembly: AssemblyVersion("1.1.0.0")]
36+
[assembly: AssemblyFileVersion("1.1.0.0")]

0 commit comments

Comments
 (0)