Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error porblems

Status
Not open for further replies.

Asbestos2

Technical User
Mar 18, 2011
22
0
0
GB
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
 
Hi

Please ignore the bit in the code above that shows

MVC Music Store Tutorial v2.0 – – Tutorial under Creative Commons Attribution 3.0 License
Page 14

I copied this in from the training notes by mistake....

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top