我正在研究MVC3项目,我想在视图中使用RedirectToAction时显示一条消息.我使用过ViewBag,但它不起作用.
请有人帮助我.
目前我正在学习ASP.NET中的新主题Web服务,但我不了解Web服务中SOAP和RESTful的概念以及如何在.NET中创建这些类型的服务.
我正在使用 Visual Studio 2013。当我要打开 MVC4 项目视图时遇到问题。它给出了以下错误。
the document cannot be opened. it has been renamed deleted or moved
我搜索并发现删除.suo文件后。是可以解决的。我做了同样的事情,问题得到了解决,但其他问题又出现了。现在它抛出对象引用错误。
Object reference not set to an instance of an object
Run Code Online (Sandbox Code Playgroud)
任何人都知道如何解决这个问题。请提出一些建议。
谢谢
我在数据库中提交一些数据,提交后我想显示相同的页面.但我正在查看文本框值不为空的页面.
ModelState.Clear();
我习惯清除文本框.
但仍然保留文本框值.请建议我在mvc3中提交后清除模型.
public ActionResult AddNewCategory(CategoryViewModel model) {
if (ModelState.IsValid) {
int result = 0;
var categoryEntity = new Category {
CategoryName = model.CategoryName, CategorySlug = model.CategorySlug
};
result = Convert.ToInt32(_categoryRepository.AddNewCategory(categoryEntity));
if (result > 0) {
ModelState.Clear();
}
}
return View(model);
}
Run Code Online (Sandbox Code Playgroud)