Nightwalker83
May 31st, 2011, 08:19 PM
Hi,
How do I convert a view model to a string? This is what I have tried but it still returning the error "Cannot implicitly convert type 'System.Web.Mvc.ViewResult' to 'string'".
public string Index()
{
//Create a list of genres
var genres = new List<string> { "Rock", "Jazz", "Country", "Pop", "Disco" };
//Create the view model
var viewModel = new StoreIndexViewModel
{
NumberOfGenres = genres.Count(), Genres = genres
};
return View(viewModel.ToString());
}
Thanks,
Nightwalker
How do I convert a view model to a string? This is what I have tried but it still returning the error "Cannot implicitly convert type 'System.Web.Mvc.ViewResult' to 'string'".
public string Index()
{
//Create a list of genres
var genres = new List<string> { "Rock", "Jazz", "Country", "Pop", "Disco" };
//Create the view model
var viewModel = new StoreIndexViewModel
{
NumberOfGenres = genres.Count(), Genres = genres
};
return View(viewModel.ToString());
}
Thanks,
Nightwalker