1
$.each(data,
   function(i, item) {
     console.log(item);
     var _seoObj = {
        SeoBaslik: item.SeoBaslik
     }
     console.log(_seoObj);
     //var urlLink = 'PhotoGallery/Details/?seoTitle=' + _seoObj.SeoBaslik;
       var urlLink = '@Url.Action("Details", "PhotoGallery", new {area="", seoTitle= _seoObj.SeoBaslik })';
 html += '<div class="col-lg-4 col-sm-6 mb-2">\
          <a href="'+urlLink+'" class="BackgroundS">\
          <div class="ImageWrapper br10"><img src="/images/empty_news.png" style="background: url(' + res.ImageUrl +') no-repeat center center; background-size: cover;" class="img-fluid br10"></div>\
          </a>\
          </div>';

I can't pull the link from the codes above, depending on root

root yapısı

localization.ForCulture("tr")
.ForController<PhotoGalleryController>()
.ForAction(x => x.Index())
.AddTranslation("fotograflar/tum-fotograf-galeriler");

localization.ForCulture("tr")
.ForController<PhotoGalleryController>()
.ForAction(x => x.Details(null))
.AddTranslation("fotograf-galeri-detay/{seoTitle}");

Action

[Route("photo-gallery-detail/{seoTitle}")\]
public ActionResult Details(string seoTitle)
{
}

when I use the closed urlLink, it gives me the url /en/photos/photogallery/details/?seoTitle=....

when I use the urlLink below The system warns that _seoObj is incorrect in new {area="", seoTitle= _seoObj.SeoTitle })

can you help me?your text

I haven't tried any

1 Answers1

0

Change this line:

var urlLink = '@Url.Action("Details", "PhotoGallery", new {area="", seoTitle= _seoObj.SeoBaslik })';

With this

var urlLink = '@Url.Action("Details", "PhotoGallery", new { area= "" })?seoTitle=' + _seoObj.SeoBaslik;

The _seoObj is defined in JS so you can't access it from the inline @Url.Action. Create the basic URL first and then concatenate other URL parameters.

vander
  • 138
  • 6