Results 1 to 5 of 5

Thread: I need help in MVC 4

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2007
    Location
    Karachi
    Posts
    551

    I need help in MVC 4

    I m following article on MVC 4 http://www.codeproject.com/Articles/...al&spc=Relaxed

    but i m not getting helloworld text on screen ..Instead its written Index..whne i press F5 the url of screen is http://localhost:65231/

    ..routeconfig.cs contain following code
    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Mvc;
    using System.Web.Routing;
    
    namespace HelloWorld
    {
        public class RouteConfig
        {
            public static void RegisterRoutes(RouteCollection routes)
            {
                routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    
                //routes.MapRoute(
                //    name: "Default",
                //    url: "{controller}/{action}/{id}",
                //    defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
                //);
    
                routes.MapRoute(
                     name: "Default",
                     url: "{controller}/{action}/{id}",
                     defaults: new { controller = "HelloWorld", action = "Index", id = UrlParameter.Optional }
                 );
            }
        }
    }

    any help
    There is no achievement without goals

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,348

    Re: I need help in MVC 4

    If you see a view then your route is presumably working. What we would need to see is your controller and your view.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2007
    Location
    Karachi
    Posts
    551

    Re: I need help in MVC 4

    here is the controller
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Mvc;

    namespace HelloWorld.Controllers
    {
    public class HelloWorldController : Controller
    {
    //
    // GET: /HelloWorld/

    public ActionResult Index()
    {
    return View();
    }

    }
    }

    and here is the view

    @{
    ViewBag.Title = "Index";
    }

    <h2>Index</h2>
    There is no achievement without goals

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2007
    Location
    Karachi
    Posts
    551

    Re: I need help in MVC 4

    i changed view like this
    @{
    ViewBag.Title = "Index";
    }

    <h2>Helloworld</h2>
    and its working fine
    There is no achievement without goals

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,348

    Re: I need help in MVC 4

    Quote Originally Posted by ERUM View Post
    its working fine
    So you'll be using the Thread Tools menu to mark this thread Resolved then.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width