1
0
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:
Uncled1023 2015-12-16 16:57:24 -08:00
parent 98c32ac9d1
commit 1d8c4fba34
4 changed files with 40 additions and 20 deletions

View File

@ -13,23 +13,40 @@ namespace Teknik.Areas.Blog
}
}
public override void RegisterArea(AreaRegistrationContext context)
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapSubdomainRoute(
"Blog_dev", // Route name
"Blog_dev_index", // Route name
"dev",
"Blog/{controller}/{action}/{username}/{id}", // URL with parameters
new { controller = "Blog", action = "Index", username = UrlParameter.Optional, id = UrlParameter.Optional } // Parameter defaults
"Blog", // URL with parameters
new { controller = "Blog", action = "Index" }, // Parameter defaults
new[] { typeof(Controllers.BlogController).Namespace }
);
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",
"{controller}/{action}/{username}/{id}", // URL with parameters
new { controller = "Blog", action = "Index", username = UrlParameter.Optional, id = UrlParameter.Optional } // Parameter defaults
"", // URL with parameters
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
BundleTable.Bundles.Add(new ScriptBundle("~/bundles/blog").Include(
"~/Scripts/ocupload/1.1.2/ocupload.js",
"~/Areas/Blog/Scripts/Blog.js"));
}
}

View File

@ -25,23 +25,26 @@ namespace Teknik.Areas.Blog.Controllers
// by default, view the teknik blog
Models.Blog blog = db.Blogs.Find(Constants.SERVERBLOGID);
if (blog == null)
{
return HttpNotFound();
}
BlogViewModel model = new BlogViewModel();
model.BlogId = blog.BlogId;
model.UserId = blog.UserId;
model.User = blog.User;
model.Posts = blog.Posts;
model.BlogId = Constants.SERVERBLOGID;
if (blog != null)
{
model.UserId = blog.UserId;
model.User = blog.User;
model.Posts = blog.Posts;
}
return View(model);
}
// GET: Blogs/Details/5
[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)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);

View File

@ -18,14 +18,14 @@ namespace Teknik.Areas.Contact
context.MapSubdomainRoute(
"Contact_dev", // Route name
"dev",
"Contact/{controller}/{action}", // URL with parameters
"Contact", // URL with parameters
new { controller = "Contact", action = "Index" }, // Parameter defaults
new[] { typeof(Controllers.ContactController).Namespace }
);
context.MapSubdomainRoute(
"Contact_default", // Route name
"contact",
"{controller}/{action}", // URL with parameters
"", // URL with parameters
new { controller = "Contact", action = "Index" }, // Parameter defaults
new[] { typeof(Controllers.ContactController).Namespace }
);

View File

@ -17,14 +17,14 @@ namespace Teknik.Areas.Profile
context.MapSubdomainRoute(
"Profile_dev", // Route name
"dev",
"Profile/{controller}/{action}", // URL with parameters
"Profile", // URL with parameters
new { controller = "Profile", action = "Index" }, // Parameter defaults
new[] { typeof(Controllers.ProfileController).Namespace }
);
context.MapSubdomainRoute(
"Profile_default", // Route name
"profile",
"{controller}/{action}", // URL with parameters
"", // URL with parameters
new { controller = "Profile", action = "Index" }, // Parameter defaults
new[] { typeof(Controllers.ProfileController).Namespace }
);