Replace querystring routes with conventional routes
This commit is contained in:
parent
1c0d2de9fe
commit
32a2d164c3
|
@ -75,6 +75,8 @@ private async Task Refresh()
|
||||||
Page page;
|
Page page;
|
||||||
User user;
|
User user;
|
||||||
List<Module> modules;
|
List<Module> modules;
|
||||||
|
int moduleid = -1;
|
||||||
|
string control = "";
|
||||||
|
|
||||||
bool reload = false;
|
bool reload = false;
|
||||||
if (PageState == null)
|
if (PageState == null)
|
||||||
|
@ -144,10 +146,30 @@ private async Task Refresh()
|
||||||
pages = PageState.Pages;
|
pages = PageState.Pages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// format path so that it can be located in the pages collection
|
||||||
if (path.IndexOf("?") != -1)
|
if (path.IndexOf("?") != -1)
|
||||||
{
|
{
|
||||||
|
// remove querystring from path
|
||||||
path = path.Substring(0, path.IndexOf("?"));
|
path = path.Substring(0, path.IndexOf("?"));
|
||||||
}
|
}
|
||||||
|
// remove admin route elements from path
|
||||||
|
string[] segments = path.Split('/');
|
||||||
|
int result;
|
||||||
|
// admin routes are in the form of path/moduleid/control or path/moduleid
|
||||||
|
if (segments.Length >= 2 && int.TryParse(segments[segments.Length - 2], out result))
|
||||||
|
{
|
||||||
|
control = segments[segments.Length - 1];
|
||||||
|
moduleid = result;
|
||||||
|
path = path.Replace("/" + moduleid.ToString() + "/" + control, "");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (segments.Length >= 1 && int.TryParse(segments[segments.Length - 1], out result))
|
||||||
|
{
|
||||||
|
moduleid = result;
|
||||||
|
path = path.Replace("/" + moduleid.ToString(), "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (PageState == null || reload == true)
|
if (PageState == null || reload == true)
|
||||||
{
|
{
|
||||||
|
@ -179,17 +201,9 @@ private async Task Refresh()
|
||||||
pagestate.User = user;
|
pagestate.User = user;
|
||||||
pagestate.Uri = new Uri(_absoluteUri, UriKind.Absolute);
|
pagestate.Uri = new Uri(_absoluteUri, UriKind.Absolute);
|
||||||
pagestate.QueryString = querystring;
|
pagestate.QueryString = querystring;
|
||||||
pagestate.ModuleId = -1;
|
pagestate.ModuleId = moduleid;
|
||||||
pagestate.Control = "";
|
pagestate.Control = control;
|
||||||
|
|
||||||
if (querystring.ContainsKey("mid"))
|
|
||||||
{
|
|
||||||
pagestate.ModuleId = int.Parse(querystring["mid"]);
|
|
||||||
}
|
|
||||||
if (querystring.ContainsKey("ctl"))
|
|
||||||
{
|
|
||||||
pagestate.Control = querystring["ctl"];
|
|
||||||
}
|
|
||||||
if (PageState != null && (PageState.ModuleId != pagestate.ModuleId || PageState.Control != pagestate.Control))
|
if (PageState != null && (PageState.ModuleId != pagestate.ModuleId || PageState.Control != pagestate.Control))
|
||||||
{
|
{
|
||||||
reload = true;
|
reload = true;
|
||||||
|
|
|
@ -44,14 +44,19 @@ namespace Oqtane.Shared
|
||||||
|
|
||||||
public static string EditUrl(PageState pagestate, Module modulestate, string action, string parameters)
|
public static string EditUrl(PageState pagestate, Module modulestate, string action, string parameters)
|
||||||
{
|
{
|
||||||
string url = pagestate.Alias.Path + "/" + pagestate.Page.Path + "?mid=" + modulestate.ModuleId.ToString();
|
string url = pagestate.Alias.Path;
|
||||||
|
if (pagestate.Page.Path != "")
|
||||||
|
{
|
||||||
|
url += "/" + pagestate.Page.Path;
|
||||||
|
}
|
||||||
|
url += "/" + modulestate.ModuleId.ToString();
|
||||||
if (action != "")
|
if (action != "")
|
||||||
{
|
{
|
||||||
url += "&ctl=" + action;
|
url += "/" + action;
|
||||||
}
|
}
|
||||||
if (!string.IsNullOrEmpty(parameters))
|
if (!string.IsNullOrEmpty(parameters))
|
||||||
{
|
{
|
||||||
url += "&" + parameters;
|
url += "?" + parameters;
|
||||||
}
|
}
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user