|
感觉你们没有用心写。net部分的后台啊,bug太多了。
这里的代码永远执行不到的,因此Baas.net的热更新没用的。
foreach (var rootPath in pathArray)
{
var requestPath = context.Request.Path;
var latePath = GetLatePath(rootPath);
var firstIndex = requestPath.IndexOf(latePath, StringComparison.Ordinal);//latePath改为effectivePrefixPath
var secondIndex = requestPath.LastIndexOf(latePath, StringComparison.Ordinal);
if (latePath == "/")
{
firstIndex = secondIndex;
}
if (!requestPath.StartsWith(effectivePrefixPath) && firstIndex == 0)
{
var newUrl = rootPath + pathMap[rootPath].LatestVersion;
if ((requestPath == rootPath + "indexUrl_in_server.txt"))
{ }
else if (requestPath == rootPath)
{
//context.RewritePath(requestPath.Replace(rootPath, requestPath + pathMap[rootPath].URL));
context.Response.Redirect(requestPath.Replace(rootPath, rootPath + pathMap[rootPath].URL));
//context.RewritePath(requestPath + pathMap[rootPath].PreQueryString, pathMap[rootPath].QueryObject, pathMap[rootPath].SuffixQueryString);
}
else if (new[] { "2", "3" }.Contains(pathMap[rootPath].Pattern))
{
if (!requestPath.Contains(newUrl))
{
var userPath = string.Empty;
if (requestPath.LastIndexOf('/') != -1)
{
userPath = requestPath.Substring(0, requestPath.LastIndexOf('/'));
}
if (!string.IsNullOrEmpty(userPath) && userPath == rootPath)
{
var questionIndex = requestPath.IndexOf("?", StringComparison.Ordinal);
string filePathAndName;
if (questionIndex != -1)
{
filePathAndName = requestPath.Substring(0, questionIndex);
}
else
{
filePathAndName = requestPath;
}
var realFile = AppDomain.CurrentDomain.BaseDirectory + filePathAndName.Replace('/', '\\');
if (!File.Exists(realFile))
{
context.Response.Redirect(rootPath + pathMap[rootPath].URL);
}
}
else if (secondIndex > firstIndex)
{
context.Response.Redirect(requestPath.Substring(0, firstIndex + rootPath.Length) +
pathMap[rootPath].LatestVersion +
requestPath.Substring(secondIndex));
}
else
{
context.Response.Redirect(rootPath + pathMap[rootPath].URL);
//context.RewritePath(requestPath.Replace(rootPath, newUrl + "/"));
}
}
}
else if (pathMap[rootPath].Pattern == "1")
{
var questionIndex = requestPath.IndexOf("?", StringComparison.Ordinal);
string filePathAndName;
if (questionIndex != -1)
{
filePathAndName = requestPath.Substring(0, questionIndex);
}
else
{
filePathAndName = requestPath;
}
var realFile = AppDomain.CurrentDomain.BaseDirectory + filePathAndName.Replace('/', '\\');
if (!File.Exists(realFile))
{
context.Response.Redirect(rootPath + pathMap[rootPath].URL);
}
}
break;
}
} |
|