I have a controller that handles several contact forms. I currently pass a model to my view. The way this is built now the URL does not change when the ContactSuccess.cshtml view is returned. I simply need to be able to change the URL, and my thinking was to add an ID querystring to the end. So instead of the URL being /contactus I want it to be /contactus?id=whatever. This project is not using the default routing.
Thanks
Here is what I have right now. This blows up the page with the following error "The view '~/Views/Contact/ContactSuccess.cshtml?id=3' or its master was not found or no view engine supports the searched locations. The following locations were searched: ~/Views/Contact/ContactSuccess.cshtml?id=3".
[HttpPost]
public ActionResult ContactUs(ContactFormViewModel data, string[] sections)
{
var id = "3";
var page = _logic.GetPage(SectionArea, PhiferBusinessLogic.PageTypes.ContactUs);
var newModel = new ContactPageViewModel(page) { FormViewModel = new ContactFormViewModel { TollFreePhone = _logic.GetAreaTollFreeNumber(SectionArea) }};
var content = _logic.GetPageContent(page.CMSPageID);
newModel.FormViewModel = data;
newModel.FormViewModel.ShouldShowContactIntroText = (SectionArea != PhiferBusinessLogic.SiteAreas.DrawnWire && SectionArea != PhiferBusinessLogic.SiteAreas.EngineeredProducts);
newModel.FormViewModel.AreaString = newModel.AreaString;
PhiferContactLogic pcl = new PhiferContactLogic();
if (content != null)
{
newModel.ContentHTML = content.ContentHTML;
}
newModel.FormViewModel.Contact = data.Contact;
if (page.CMSAreaID != 2 && String.IsNullOrWhiteSpace(data.Contact.Company))
{
ModelState.AddModelError("Contact.Company", "Company is required.");
}
ModelState.Remove("Sections");
if (ModelState.IsValid)
{
var contact = new Contact();
contact.Name = data.Contact.Name;
contact.Email = data.Contact.Email;
contact.Phone = data.Contact.Phone;
contact.City = data.Contact.City;
contact.State = data.Contact.State;
contact.Zip = data.Contact.Zip;
contact.Company = data.Contact.Company;
contact.Comments = data.Contact.Comments;
contact.Address = data.Contact.Address;
contact.Website = data.Contact.Website;
contact.PhiferAccountRep = data.Contact.PhiferAccountRepresentative;
contact.Country = data.Contact.Country;
contact.IP = data.Contact.IP;
contact.EmailTemplate = data.Contact.EmailTemplate;
var sectionSlugs = new List<string>();
sectionSlugs.Add(GetAreaContactSectionSlug(SectionArea));
if (sections != null)
{
sectionSlugs.AddRange(sections);
}
pcl.CreateContact(contact, sectionSlugs.ToArray());
//current email method call
pcl.EmailContactFormContacts(contact, sectionSlugs.ToArray());
//send email to visitor
Email.Email.GenerateTemplate(contact.Name, contact.Email, contact.EmailTemplate);
return View("~/Views/Contact/ContactSuccess.cshtml", newModel);
}
newModel.BreadCrumbHTML = "<a href='/" + SectionSlug + "'>" + SectionName + "</a> > <span>Contact Us</span>";
//This is the current return View
//return View("~/Views/Contact/Contact.cshtml", newModel);
return View ("~/Views/Contact/Contact.cshtml?id=" + id, newModel);
}