title: script for window.location.href error
body: <p>this Q. is a continue of this question <a href="https://stackoverflow.com/questions/41441305/passing-dataid-with-redircettoaction-to-url-using-viewmodel?noredirect=1#comment70093767_41441305">first qestion</a> I have a form that I need to redirect to action with the form uploaded details (just like In stackoverflow) , but apparently because i'm using Ajax , it prevent it from redirect , I have tried to add my Ajax a redirect but I keep getting error and wrong Url . it should redirect from <a href="http://localhost:1914/En/VoosUp/Create" rel="nofollow noreferrer">http://localhost:1914/En/VoosUp/Create</a> To <a href="http://localhost:1914/En/events/Index/42" rel="nofollow noreferrer">http://localhost:1914/En/events/Index/42</a> (E.G. Id number) the results i'm getting with what I wrote are in my Js Code 
  How can I redirect it to the correct url  (Events/Index/Id )
  Thanks in advance 
  Js </p>
  
  <pre><code>function GetLocation() {
      var geocoder = new window.google.maps.Geocoder();
  
      var street = document.getElementById('txtAddress').value;
      var city = document.getElementById('txtCity').value;
      var address = city + street;
      console.log(address);
      var labelLat = document.getElementById('Latitude');
      var labellong = document.getElementById('longitude');
  
      geocoder.geocode({ 'address': address },
          function(results, status) {
              if (status == window.google.maps.GeocoderStatus.OK) {
                  var latitude = results[0].geometry.location.lat();
                  var longitude = results[0].geometry.location.lng();
                  console.log("Latitude: " + latitude + "\nLongitude: " + longitude); //Ok.
  
                  labelLat.value = latitude; //Ok.
                  labellong.value = longitude;
                  var form = $('#RestoForm')[0];
                  var formData = new FormData(form);
                  $.ajax({
                      url: 'Create',
                      type: 'POST',
                      contentType: false,
                      processData: false,
                      data: formData,
                      datatype: "html",
                      success: function(data) {
                          $('#RestoForm').html(data),
                              //   window.location.href = '@Url.Content:("~/Events/Index")' + "Id";
                              //= A potentially dangerous Request.Path value was detected from the client (:).
                              // En/VoosUp/@Url.Content:("~/Events/Index")Id
                              window.location.href = '@Url.Action("~/Events/Index")';
                          // =The resource cannot be found &gt;
                          //En/VoosUp/@Url.Action("Events/Index 
  
                      }
  
                  });
  
                  error: function e(xhr, ajaxOptions, thrownError) {
                      alert(xhr.status);
                      alert(thrownError);
                  }
              }
          });
  };` 
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code> [Authorize]
      public ActionResult Create()
      {
          var viewModel = new LectureFormViewModel
          {
              Genres = _context.Genres.ToList(),
  
          };
          return View("Gigform", viewModel);
      }
  
      [Authorize, HttpPost]
      public ActionResult Create(LectureFormViewModel viewModel)
      {
  
          if (!ModelState.IsValid)
          {
              viewModel.Genres = _context.Genres.ToList();
  
              return View("Gigform", viewModel);
          }
  
  
          var lectureGig = new LectureGig
          {
             //Parameters
          };
  
          _context.LectureGigs.Add(lectureGig);
          _context.SaveChanges();
  
          // return this.RedirectToAction( "events", (c=&gt;c.Index(lectureGig.Id));
          return RedirectToAction("index", "Events", new { id = lectureGig.Id });
      }
  </code></pre>
  
  <p>and the target </p>
  
  <pre><code> public ActionResult Index(int id)
      {
          var lecturegig = _context.LectureGigs.Include(g =&gt; g.Artist)
             .Include(g =&gt; g.Genre)
             .SingleOrDefault(g =&gt; g.Id == id);
          if (lecturegig == null)
              return HttpNotFound();
          var viewmodel = new GigDetailViewModel { LectureGig = lecturegig };
  
          return View("index", viewmodel);
      }
  </code></pre>