我对Seo路由有疑问。简述如下。 某些页面具有固定的Urls,不能更改任何ID或参数。 其中之一是;
[Route("adres-secimi")]
[HttpGet]
public ActionResult Step2()
{
List<DashboardAddressModel> modelList = _authentication.GetUserData().AddressList.Select(x => new DashboardAddressModel
{
Id = x.Id,
Tittle = x.Title,
FullName = x.RecipientFullName,
Phone = x.RecipientPhoneNummer,
Detail = x.Details,
IsDefault = x.IsDefault,
CityName = x.District.City.Name,
DistrictName = x.District.Name,
Identity = x.RecipientIdentityNumber
}).ToList();
return View(modelList.OrderBy(x => !x.IsDefault).ToList());
}
有些页面具有动态网址。其中有两个;
1)
[Route("{child}")]
public ActionResult Index(string child)
{
Category childCategory = _categoryService.GetByUrl(child);
if (childCategory != null)
{
if (childCategory.ProductList.Count > 0)
{
return RedirectToAction("SingleProduct", new { child = childCategory });
}
else if (childCategory.ChildCategoryList.Count > 0)
{
CategoryIndexModel model = new CategoryIndexModel
{
ChildId = childCategory.Id,
ChildUrl = childCategory.Url,
ChildName = childCategory.TitleName,
MetaDescription = childCategory.MetaDescription,
MetaKeywords = childCategory.MetaKeywords
};
return View(model);
}
}
return RedirectToAction("Index", "Home");
}
2)
[Route("{parent}/{child}/{productId:int}")]
public ActionResult SingleProduct(string parent,string child, int productId)
{
Category childCategory = _categoryService.GetByUrl(child);
Category parentCategory = _categoryService.GetByUrl(parent);
Product product = _productService.GetById(productId);
SingleProductCategoryModel model = new SingleProductCategoryModel
{
ChildId = childCategory.Id,
ChildName = childCategory.TitleName,
ChildLink = childCategory.Link,
ParentName = parentCategory.TitleName,
ParentId = (int?)parentCategory.Id,
ParentLink = parentCategory.Link,
Rating = childCategory.Rating,
IsInWishList = (_authentication.GetUserData() != null) ? _authentication.GetUserData().WishList.Any(w => w.IsActive && w.CategoryId == childCategory.Id) : false,
ProductId = product.Id,
MetaDescription = childCategory.MetaDescription,
MetaKeywords = childCategory.MetaKeywords,
InformationText = childCategory.InformationText,
DescriptionList = childCategory.DescriptionList.Select(x => new SingleProductDescriptionModel
{
Type = x.Type,
Name = Utility.Converter.GetDescriptionName(x.Type),
Content = x.Content
}).ToList(),
BigImageList = childCategory.ImageList.Where(x => x.Type == ImageTypes.slider_big_img).Select(x => new SingleProductImageModel
{
Type = x.Type,
Path = x.Path,
Description = x.Description,
DisplayOrder = x.DisplayOrder - 1
}).ToList(),
SmallImageList = childCategory.ImageList.Where(x => x.Type == ImageTypes.slider_small_img).Select(x => new SingleProductImageModel
{
Type = x.Type,
Path = x.Path,
Description = x.Description,
DisplayOrder = x.DisplayOrder - 1
}).ToList(),
CommentCount = childCategory.CommentList.Where(x => x.IsActive).Count()
};
return View(model);
}
当我尝试访问动态url时,它们正在路由正确的操作,但是在定义了动态url的路由之后,固定路由开始出现错误“多个url匹配”。 如果有人可以帮助我提供解决方案,我将非常高兴。 并在网址上显示产品ID并不是最好的解决方案,也许您有更好的主意?