mirror of
https://git.teknik.io/Teknikode/Teknik.git
synced 2023-08-02 14:16:22 +02:00
Modified routing to better match real URL.
This commit is contained in:
parent
98c32ac9d1
commit
1d8c4fba34
@ -13,23 +13,40 @@ namespace Teknik.Areas.Blog
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void RegisterArea(AreaRegistrationContext context)
|
public override void RegisterArea(AreaRegistrationContext context)
|
||||||
{
|
{
|
||||||
context.MapSubdomainRoute(
|
context.MapSubdomainRoute(
|
||||||
"Blog_dev", // Route name
|
"Blog_dev_index", // Route name
|
||||||
"dev",
|
"dev",
|
||||||
"Blog/{controller}/{action}/{username}/{id}", // URL with parameters
|
"Blog", // URL with parameters
|
||||||
new { controller = "Blog", action = "Index", username = UrlParameter.Optional, id = UrlParameter.Optional } // Parameter defaults
|
new { controller = "Blog", action = "Index" }, // Parameter defaults
|
||||||
|
new[] { typeof(Controllers.BlogController).Namespace }
|
||||||
);
|
);
|
||||||
context.MapSubdomainRoute(
|
context.MapSubdomainRoute(
|
||||||
"Blog_default", // Route name
|
"Blog_dev_detail", // Route name
|
||||||
|
"dev",
|
||||||
|
"Blog/{username}/{id}", // URL with parameters
|
||||||
|
new { controller = "Blog", action = "Details", username = "", id = UrlParameter.Optional }, // Parameter defaults
|
||||||
|
new[] { typeof(Controllers.BlogController).Namespace }
|
||||||
|
);
|
||||||
|
context.MapSubdomainRoute(
|
||||||
|
"Blog_default_index", // Route name
|
||||||
"blog",
|
"blog",
|
||||||
"{controller}/{action}/{username}/{id}", // URL with parameters
|
"", // URL with parameters
|
||||||
new { controller = "Blog", action = "Index", username = UrlParameter.Optional, id = UrlParameter.Optional } // Parameter defaults
|
new { controller = "Blog", action = "Index" }, // Parameter defaults
|
||||||
|
new[] { typeof(Controllers.BlogController).Namespace }
|
||||||
|
);
|
||||||
|
context.MapSubdomainRoute(
|
||||||
|
"Blog_default_detail", // Route name
|
||||||
|
"blog",
|
||||||
|
"{username}/{id}", // URL with parameters
|
||||||
|
new { controller = "Blog", action = "Details", username = "", id = UrlParameter.Optional }, // Parameter defaults
|
||||||
|
new[] { typeof(Controllers.BlogController).Namespace }
|
||||||
);
|
);
|
||||||
|
|
||||||
// Register Bundles
|
// Register Bundles
|
||||||
BundleTable.Bundles.Add(new ScriptBundle("~/bundles/blog").Include(
|
BundleTable.Bundles.Add(new ScriptBundle("~/bundles/blog").Include(
|
||||||
|
"~/Scripts/ocupload/1.1.2/ocupload.js",
|
||||||
"~/Areas/Blog/Scripts/Blog.js"));
|
"~/Areas/Blog/Scripts/Blog.js"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,23 +25,26 @@ namespace Teknik.Areas.Blog.Controllers
|
|||||||
|
|
||||||
// by default, view the teknik blog
|
// by default, view the teknik blog
|
||||||
Models.Blog blog = db.Blogs.Find(Constants.SERVERBLOGID);
|
Models.Blog blog = db.Blogs.Find(Constants.SERVERBLOGID);
|
||||||
if (blog == null)
|
|
||||||
{
|
|
||||||
return HttpNotFound();
|
|
||||||
}
|
|
||||||
BlogViewModel model = new BlogViewModel();
|
BlogViewModel model = new BlogViewModel();
|
||||||
model.BlogId = blog.BlogId;
|
model.BlogId = Constants.SERVERBLOGID;
|
||||||
model.UserId = blog.UserId;
|
if (blog != null)
|
||||||
model.User = blog.User;
|
{
|
||||||
model.Posts = blog.Posts;
|
model.UserId = blog.UserId;
|
||||||
|
model.User = blog.User;
|
||||||
|
model.Posts = blog.Posts;
|
||||||
|
}
|
||||||
|
|
||||||
return View(model);
|
return View(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
// GET: Blogs/Details/5
|
// GET: Blogs/Details/5
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
public ActionResult Details(int? id)
|
public ActionResult Details(string username, int? id)
|
||||||
{
|
{
|
||||||
|
if (string.IsNullOrEmpty(username))
|
||||||
|
{
|
||||||
|
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
|
||||||
|
}
|
||||||
if (id == null)
|
if (id == null)
|
||||||
{
|
{
|
||||||
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
|
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
|
||||||
|
@ -18,14 +18,14 @@ namespace Teknik.Areas.Contact
|
|||||||
context.MapSubdomainRoute(
|
context.MapSubdomainRoute(
|
||||||
"Contact_dev", // Route name
|
"Contact_dev", // Route name
|
||||||
"dev",
|
"dev",
|
||||||
"Contact/{controller}/{action}", // URL with parameters
|
"Contact", // URL with parameters
|
||||||
new { controller = "Contact", action = "Index" }, // Parameter defaults
|
new { controller = "Contact", action = "Index" }, // Parameter defaults
|
||||||
new[] { typeof(Controllers.ContactController).Namespace }
|
new[] { typeof(Controllers.ContactController).Namespace }
|
||||||
);
|
);
|
||||||
context.MapSubdomainRoute(
|
context.MapSubdomainRoute(
|
||||||
"Contact_default", // Route name
|
"Contact_default", // Route name
|
||||||
"contact",
|
"contact",
|
||||||
"{controller}/{action}", // URL with parameters
|
"", // URL with parameters
|
||||||
new { controller = "Contact", action = "Index" }, // Parameter defaults
|
new { controller = "Contact", action = "Index" }, // Parameter defaults
|
||||||
new[] { typeof(Controllers.ContactController).Namespace }
|
new[] { typeof(Controllers.ContactController).Namespace }
|
||||||
);
|
);
|
||||||
|
@ -17,14 +17,14 @@ namespace Teknik.Areas.Profile
|
|||||||
context.MapSubdomainRoute(
|
context.MapSubdomainRoute(
|
||||||
"Profile_dev", // Route name
|
"Profile_dev", // Route name
|
||||||
"dev",
|
"dev",
|
||||||
"Profile/{controller}/{action}", // URL with parameters
|
"Profile", // URL with parameters
|
||||||
new { controller = "Profile", action = "Index" }, // Parameter defaults
|
new { controller = "Profile", action = "Index" }, // Parameter defaults
|
||||||
new[] { typeof(Controllers.ProfileController).Namespace }
|
new[] { typeof(Controllers.ProfileController).Namespace }
|
||||||
);
|
);
|
||||||
context.MapSubdomainRoute(
|
context.MapSubdomainRoute(
|
||||||
"Profile_default", // Route name
|
"Profile_default", // Route name
|
||||||
"profile",
|
"profile",
|
||||||
"{controller}/{action}", // URL with parameters
|
"", // URL with parameters
|
||||||
new { controller = "Profile", action = "Index" }, // Parameter defaults
|
new { controller = "Profile", action = "Index" }, // Parameter defaults
|
||||||
new[] { typeof(Controllers.ProfileController).Namespace }
|
new[] { typeof(Controllers.ProfileController).Namespace }
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user