ASP.NET MVC as a frontend

6 views
Skip to first unread message

Vitaly Lopatkin

unread,
Mar 20, 2011, 2:02:40 PM3/20/11
to Tuura project
A demo project is here http://tuura.dyndns.org:88 ,
The sources are here http://tuura.dyndns.org:88/MvcApplication1.zip

You'd probably be interested in the following files:
- Controllers\ProblemsController.cs
- Models\RegisterProblemModels.cs
- Views\Problems\*.*

The other files are generated by Visual Studio and are not very
interesting.

There is no DB in the demo, so the data you enter may get lost
occasionally.

Andrey Mokhov

unread,
Mar 20, 2011, 5:48:12 PM3/20/11
to Tuura project
Thanks!

The sources look fine to me. I mean I can understand them easier than
Haskell's %)

There is a lot of extra code which was generated by VS (I don't
usually like that), but on the other hand the pages look more finished
visually because VS does a lot of things on behalf of the programmer.
That's the advantage of such well-established languages as C#.
Arseniy's webpages require a lot of polishing and I'm not sure how
easy it is to do using rudimentary Haskell's IDEs.

Still, the question .NET != MS stands. Can we do the same using only
freely available tools?

Vitaly Lopatkin

unread,
Mar 21, 2011, 3:15:38 AM3/21/11
to Tuura project
> Still, the question .NET != MS stands. Can we do the same using only
> freely available tools?

For IDE you can use Visual Web Developer Express http://www.microsoft.com/express/Web/
or SharpDevelop on Windows or mono-develop on Linux. Though i don't
like IDEs other then the MS one.

As for runtime, I've tried to deploy the demo on ubuntu server. It
works, but I've got an NotImplementedException in
StringLengthAttribute. The version of Mono is 2.6.7. So if we need the
project working on Linux with ASP.NET frontend it requires extensive
testing of obvious things.

Ivan V. Polyakov

unread,
Mar 21, 2011, 6:48:27 AM3/21/11
to tuurap...@googlegroups.com
> There is a lot of extra code which was generated by VS (I don't
> usually like that), but on the other hand the pages look more finished
> visually because VS does a lot of things on behalf of the programmer.
> That's the advantage of such well-established languages as C#.
> Arseniy's webpages require a lot of polishing and I'm not sure how
> easy it is to do using rudimentary Haskell's IDEs.

Well, VS has nothing to do with how the page looks, you can attach a
fancy CSS to Arseniy's pages and they will look the same. Ashur used
to like writing CSS files :)

Andrey Mokhov

unread,
Mar 21, 2011, 8:51:50 PM3/21/11
to Tuura project
> Well, VS has nothing to do with how the page looks, you can attach a
> fancy CSS to Arseniy's pages and they will look the same. Ashur used
> to like writing CSS files :)

Sure, we can use any CSS :) I meant this one was generated
automatically from some layout with proper alignment of buttons etc.
Having such tools within IDE is convenient. Otherwise we'll have to
use other tools and/or do manual layout/fiddling with CSS whenever we
decide to change anything on the website.

Arseniy Alekseyev

unread,
Mar 22, 2011, 11:42:18 AM3/22/11
to tuurap...@googlegroups.com, Andrey Mokhov
> ...page looks...

> I meant this one was generated automatically
Was it? Vitaly listed the HTML template
(Views\Problems\AddProblem.aspx) as one of the "interesting" files, so
it probably wasn't generated.

By the way, I had a hard time understanding how the controllers are
being used. The ProblemsController is instantiated from the
ControllerFactory (on the condition of string equality!!), which is
not called from user code, but rather fed into some static (?) method
ControllerBuilder.Current.SetControllerFactory. I can't tell what
happens next. How are these controllers created and how are they
associated with Views? Is it via Html.ActionLink("Add problem",
"AddProblem", "Problems")? I guess reflection is used to handle this
(note the strings all around the place), and it makes the code hard to
understand and especially hard to maintain.

I am sure that C# can do better (that is it can do fine without
run-time reflection), so I don't really like the proposed approach.

Vitaly Lopatkin

unread,
Mar 22, 2011, 1:09:51 PM3/22/11
to Tuura project

> Was it? Vitaly listed the HTML template
> (Views\Problems\AddProblem.aspx) as one of the "interesting" files, so
> it probably wasn't generated.

Only a part of the file is generated.


> By the way, I had a hard time understanding how the controllers are
> being used. The ProblemsController is instantiated from the
> ControllerFactory (on the condition of string equality!!), which is
> not called from user code, but rather fed into some static (?) method
> ControllerBuilder.Current.SetControllerFactory. I can't tell what
> happens next.

The string equality is mine. :) You'd use some DI instead. The default
implementation of ContollerFactory expects parameterless constructor
in a Controller class.

> How are these controllers created and how are they
> associated with Views?

Controllers are created in ControllerFactory.
There is a default naming convention:
XyzController class is a controller with name Xyz and it's views are
located in Views\Xyz\ directory.
View's names are equal to controller actions.
You can specify any view name you like in parameter of a View() method
call in an controller's action.

> Is it via Html.ActionLink("Add problem",
> "AddProblem", "Problems")? I guess reflection is used to handle this
> (note the strings all around the place), and it makes the code hard to
> understand and especially hard to maintain.

I don't know exactly whether reflection is used or some other
technique on core level, but in most places you have to specify
controller and action name as a string. Anyway you can write\google
for some class to eliminate string from your code or provide your own
way to link a controller name to a controller type.
Reply all
Reply to author
Forward
0 new messages