Asp.net MVC5 How can I shorten the URL of item so that It uses less space on database . I get the following error

0

Problem description: As an example Ebay link

Can be shortened to https://www.ebay.com/itm//263591535536, so that it takes less space on the database . I try to capture the full url in Razer page and then in the Controller I try to shorten it . Then I get the validation error . My code is:

if (ModelState.IsValid)
{
    db.Entry(home).State = EntityState.Modified;
    home.DetailUrl = RealHouses2.Models.Miscellaneous.RemoveExtraCharFromUrl(home.DetailUrl);

    db.SaveChanges();

    return RedirectToAction("Index");
}
return View(home);

Error message is:

System.Data.Entity.Validation.DbEntityValidationException HResult=0x80131920 Message=Validation failed for one or more entities. See 'EntityValidationErrors' property for more details.

asp.net
asp.net-mvc-5
asked on Stack Overflow Nov 28, 2019 by Sam Patirage • edited Nov 28, 2019 by Mike Brind

1 Answer

0

Thanks, Nick.McDermaid. Yes the issue is my method to reduce the URL length does not produce the correct url. So it produce a validation error. That corrected my mistake.

answered on Stack Overflow Nov 30, 2019 by Sam Patirage

User contributions licensed under CC BY-SA 3.0