NA(Hey_Nerds:MVC.Question) as ActionResult = IIF("POA", "Bonanza, "NA")

SixPapaCharlie

May the force be with you
Joined
Aug 8, 2013
Messages
16,014
Display Name

Display name:
Sixer
I create an MVC controller class.
I name it "EmanController" and give it a method Index()

Now when I call that page, I just call www....com/Eman
Does it just ignore the "controller" portion of the class name?

I am not using a whole word anywhere in my code for a controller but I can call it from a browser using the whole word minus "Controller"

It doesn't make sense to me.

In the example given, it seems it would make sense if I did:
Public Class Eman since "Eman" is stand alone
But being to call EmanController through a browser using Eman stand alone, rubs me the wrong way. What happens if I create a class just called Controller?

What am I missing?
 
Hmmmm.
I just created one called "controller"
The IDE allowed me to do it but it cannot be accessed.

I appended "X" to the beginning and just called "X" and it worked.
I have a fundamental issue with this.
 
Ya know ya shouldn't cuss like that on this here forum. ;)

edit: I was going for a nerd, not understanding a thing therefore it must be curse words and..... eman f%&^ed it up.
 
Last edited:
I create an MVC controller class.
I name it "EmanController" and give it a method Index()

Now when I call that page, I just call www....com/Eman
Does it just ignore the "controller" portion of the class name?

I am not using a whole word anywhere in my code for a controller but I can call it from a browser using the whole word minus "Controller"

It doesn't make sense to me.

In the example given, it seems it would make sense if I did:
Public Class Eman since "Eman" is stand alone
But being to call EmanController through a browser using Eman stand alone, rubs me the wrong way. What happens if I create a class just called Controller?

What am I missing?

You got it. It's "Convention over configuration". The first framework I used that really pushed this was Ruby on Rails, and Microsoft adopted it with their MVC and WebAPI frameworks. It simplifies things in the long run especially as the app grows. The views should be similarly arranged where the directory is the controller name and the method is the filename. However, all of this can be overridden (e.g. config.Routes).
 
I am old and this is a very hard concept to grasp. I'm going through some tutorial and creating a class somehow generated a database on the Fly for me when really what I want to do is connect to an existing database like I normally would. I think I'm going to go to a college and hire a tutor to sit down with me and work on this. The world has changed so much and I'm not young so I don't feel like it's for the better
 
I'm working in ASP.NET, and this looks like it so I'm going to assume that's what you're working in.

There's some work that the framework is doing for you behind the scenes that ties a URL to a controller action. The convention that it uses when it does that is to let you access the controller with a URL that matches the name of the controller class without the word "Controller". All that is overrideable by registering your own custom routes, so you can add a route to a class that doesn't end in Controller, or add a route to your "Controller" class or even remove the route to your "EmanController".

Here's a blog post I found on google and skimmed that seems to talk about it.

https://weblogs.asp.net/scottgu/asp-net-mvc-framework-part-2-url-routing
 
I really have issue with it allowing it. If I created a variable called fumanchu, I shouldn't be allowed to access it by calling fu.

Or fum or fuma or fuman or fumanc....

I like the end result of mvc but building it is whacky as hell
 
I'm going back to the pigeon droppings corroding aluminum thread...
 
Back
Top