public async Task <IActionResult> Edit(string id, [Bind("OldUrlID,URL,MemberID")] OldUrl oldUrl) { if (id != oldUrl.OldUrlID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(oldUrl); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OldUrlExists(oldUrl.OldUrlID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(oldUrl)); }
public async Task <IActionResult> Create([Bind("OldUrlID,URL,MemberID")] OldUrl oldUrl) { if (ModelState.IsValid) { _context.Add(oldUrl); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(oldUrl)); }
public bool PerformRedirect(HttpContextBase context) { HttpContextBase cb; var url = context.Request.Url.ToString().ToLower(); if (url.Contains(OldUrl.ToLower())) { context.Response.Status = "301 Moved Permanently"; context.Response.AddHeader("Location", url.Replace(OldUrl, NewUrl)); return(true); } return(false); }