Hi mukesh1,
You need to convert the url to AbsoluteUri.
Then set the path in a property and use that in the JavaScript.
Refer below sample.
HTML
<div id="main">
<div id="titlebar">
<div id="metainfo">
<span id="book-title"></span>
<span id="title-seperator"> – </span>
<span id="chapter-title"></span>
</div>
</div>
<div id="divider"></div>
<div id="prev" class="arrow">‹</div>
<div id="viewer"></div>
<div id="next" class="arrow">›</div>
</div>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.5/jszip.min.js"></script>
<script type="text/javascript" src="/Scripts/epub.js"></script>
<script type="text/javascript" src="/Scripts/reader.js"></script>
<link rel="stylesheet" href="CSS/main.css">
<script type="text/javascript">
window.onload = function () {
ePubReader("<%=epubPath%>");
};
</script>
Code
C#
protected string epubPath { get; set; }
protected void Page_Load(object sender, EventArgs e)
{
epubPath = GetUrl("alice.epub");
}
protected string GetUrl(string filePath)
{
string[] splits = Request.Url.AbsoluteUri.Split('/');
if (splits.Length >= 2)
{
string url = splits[0] + "//";
for (int i = 2; i < splits.Length - 1; i++)
{
url += splits[i];
url += "/";
}
return url + filePath;
}
return filePath;
}
VB.Net
Protected Property epubPath As String
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
epubPath = GetUrl("alice.epub")
End Sub
Protected Function GetUrl(ByVal filePath As String) As String
Dim splits As String() = Request.Url.AbsoluteUri.Split("/"c)
If splits.Length >= 2 Then
Dim url As String = splits(0) & "//"
For i As Integer = 2 To splits.Length - 1 - 1
url += splits(i)
url += "/"
Next
Return url & filePath
End If
Return filePath
End Function
You need to add the mime type th the web config inside the system.webServer section.
<system.webServer>
<staticContent>
<mimeMap fileExtension=".epub" mimeType="application/octet-stream" />
</staticContent>
</system.webServer>
Screenshot