Hi,
I have a magazine on the web that was using asp.net web files. I am changing to asp.net core mvc files. The magazine is JavaScript files. I changed the default aspx files to html and cs files in the www root files. Is there a way that I can have a folder on the main part of core files with the htm, cs and javascirpt files instead of in the www.root folder.
Below is the new html file and cs that that should open the JavaScript mag.
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimal-ui">
<meta name="apple-mobile-web-app-capable" content="yes" />
<title>Bumples Magazine</title>
<link rel="shortcut icon" href="../Bumples/FavIcon.ico" />
<link rel="icon" type="image/x-icon" href="../FavIcon.ico" />
<link rel="stylesheet" type="text/css" href="../Css/MagazineStyles.css">
<script type="javascript/text"></script>
<script src="jquery.js"></script>
</head>
<body onLoad="BmOnLoad();">
<form id="form1" runat="server">
</form>
</body>
</html>
using System;
using System.IO;
namespace Bumples
{
public partial class IssuesDefault : BasePage
{
private Int32 issue = 0;
private String section = "";
protected void Page_Load(object sender, EventArgs e)
{
//
if (String.IsNullOrEmpty(this.Request.QueryString["Issue"]))
{
this.issue = 1;
//throw new SecurityException("Error loading Issue!");
}
else
{
try
{
this.issue = Int32.Parse(this.Request.QueryString["Issue"]);
}
catch
{
this.issue = 1;
}
}
if (issue < 1 || issue > 25)
{
issue = 1;
}
//
if (String.IsNullOrEmpty(this.Request.QueryString["Section"]))
this.section = "";
else
this.section = this.Request.QueryString["Section"];
if (this.IssueName() == "Issue003" || this.IssueName() == "Issue004" || this.IssueName() == "Issue005" || this.IssueName() == "Issue006")
{
if (this.User.Identity.IsAuthenticated && (
this.User.IsInRole("Administrators") ||
this.User.IsInRole("Issue003") || this.User.IsInRole("Issue004") || this.User.IsInRole("Issue005") || this.User.IsInRole("Issue006") || this.User.IsInRole("Register")))
{
;
}
else
{
//String page = System.Web.HttpContext.Current.Request.Url.AbsoluteUri; // this.GetCurrentPageName();
this.Response.Redirect("~/Account/Login.aspx");
//throw new SecurityException("You are not allowed to edit existent articles!");
}
}
/* Execute */
this.LoadJavaScript();
/* Execute */
}
private void LoadJavaScript()
{
String javaScript = "";
javaScript += LoadFile("~/Issues/JavaScript/Movime.js");
javaScript += LoadFile("~/Issues/JavaScript/DivClass.js");
javaScript += LoadFile("~/Issues/JavaScript/MoveObjectsTo.js");
javaScript += LoadFile("~/Issues/JavaScript/MemoryClass.js");
javaScript += LoadFile("~/Issues/JavaScript/Magazine.js");
javaScript += LoadFile("~/Issues/JavaScript/TalkingBalloon.js");
javaScript += LoadFile("~/Issues/" + this.IssueName() + "/JavaScript.js");
Page.ClientScript.RegisterStartupScript(this.GetType(), "", javaScript, true);
}
public String LoadCss()
{
return "<style type=\"text/css\"> " + LoadFile("~/Issues/" + this.IssueName() + "/CssStyles.css") + " </style>";
}
private String IssueName()
{
return "Issue" + ((this.issue < 100) ? "0" : "") + ((this.issue < 10) ? "0" : "") + this.issue.ToString().Trim() + this.section;
}
private String LoadFile(String fileName)
{
//Open a file for reading
fileName = Server.MapPath(fileName);
//Get a StreamReader class that can be used to read the file
StreamReader objStreamReader = File.OpenText(fileName);
//Now, read the entire file into a string
String fileContent = objStreamReader.ReadToEnd();
objStreamReader.Close();
return fileContent;
}
}
}
Thanks,
Jen