Hi
I am new to .ASP net and have downloaded all i can and I am using MS Visual Web developer expresss 2010. I am following some training notes which is showing me how to add a controller but it doesnt seem to work.
This is what the training notes tell me to do
This will create a new file, HomeController.cs, with the following code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace MvcMusicStore.Controllers
{
public class HomeController : Controller
MVC Music Store Tutorial v2.0 – – Tutorial under Creative Commons Attribution 3.0 License
Page 14
{
//
// GET: /Home/
public ActionResult Index()
{
return View();
}
}
}
To start as simply as possible, let’s replace the Index method with a simple method that just returns a string. We’ll make two simple changes:
? Change the method to return a string instead of an ActionResult
? Change the return statement to return “Hello from Home”
The method should now look like this:
public string Index()
{
return "Hello from Home";
}
I create the Homecontroller but instead of naming it HomeController.cs it names it Homecontroller.vb.
The code it creates for ma also looks different than above and I get this
Namespace MvcMusicStore
Public Class HomeController
Inherits System.Web.Mvc.Controller
'
' GET: /Home
Function Index() As ActionResult
Return View()
End Function
End Class
End Namespace
I have tried to change the programming and the function now looks like
Function Index() As String
{
return "Hello from Home";
}
End Function
I then get build errors
Can someone advise why iget .VB and not .CS and why my script is different and finally not working.
Thanks
I am new to .ASP net and have downloaded all i can and I am using MS Visual Web developer expresss 2010. I am following some training notes which is showing me how to add a controller but it doesnt seem to work.
This is what the training notes tell me to do
This will create a new file, HomeController.cs, with the following code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace MvcMusicStore.Controllers
{
public class HomeController : Controller
MVC Music Store Tutorial v2.0 – – Tutorial under Creative Commons Attribution 3.0 License
Page 14
{
//
// GET: /Home/
public ActionResult Index()
{
return View();
}
}
}
To start as simply as possible, let’s replace the Index method with a simple method that just returns a string. We’ll make two simple changes:
? Change the method to return a string instead of an ActionResult
? Change the return statement to return “Hello from Home”
The method should now look like this:
public string Index()
{
return "Hello from Home";
}
I create the Homecontroller but instead of naming it HomeController.cs it names it Homecontroller.vb.
The code it creates for ma also looks different than above and I get this
Namespace MvcMusicStore
Public Class HomeController
Inherits System.Web.Mvc.Controller
'
' GET: /Home
Function Index() As ActionResult
Return View()
End Function
End Class
End Namespace
I have tried to change the programming and the function now looks like
Function Index() As String
{
return "Hello from Home";
}
End Function
I then get build errors
Can someone advise why iget .VB and not .CS and why my script is different and finally not working.
Thanks