Open RehanSaeed opened 4 years ago
Saif commented on 2015-05-23 13:43:31
I've started reading some of your blog posts, and some are quite interesting . Keep it up!
BlueInt32 commented on 2015-06-09 20:55:37
Good article, thanks !
http://contrastrebellion.com though...
Muhammad Rehan Saeed commented on 2015-06-10 08:18:51
Good article, thanks !
http://contrastrebellion.com though...
Thanks, I've now increased the contrast. Let me know what you think.
Frank Fajardo commented on 2015-07-20 01:08:21
I like the use of nameof
on controller and method names. As for the string interpolation, would that cause an issue when refactoring?
Muhammad Rehan Saeed commented on 2015-07-20 07:04:07
I like the use of
nameof
on controller and method names. As for the string interpolation, would that cause an issue when refactoring?
That's what I thought initially, until I used the feature in Visual Studio. The parameters in the string are not actually strings (They are not highlighted red in VS) but are still parameters. Renaming the variable will still have an effect on the name of the parameter in the string.
Frank Fajardo commented on 2015-07-21 23:55:17
That's what I thought initially, until I used the feature in Visual Studio. The parameters in the string are not actually strings (They are not highlighted red in VS) but are still parameters. Renaming the variable will still have an effect on the name of the parameter in the string.
Thanks Rehan! Great post.
Frank Fajardo commented on 2015-07-24 01:55:07
That's what I thought initially, until I used the feature in Visual Studio. The parameters in the string are not actually strings (They are not highlighted red in VS) but are still parameters. Renaming the variable will still have an effect on the name of the parameter in the string.
One thing I think they also introduced are the asp-controller and asp-action attributes to specify which controller and method to call, like so:
<a asp-controller="Home" asp-action="Index" rel="nofollow">Home</a>
I assume you can remove the use of strings here and instead use the nameof()
operator like you did in the ActionLink
.
One thing that just clicked in my mind: would nameof(HomeController)
return Home
and not HomeController
? Where did it get the name from? Or was it determined out of (MVC route) convention?
Muhammad Rehan Saeed commented on 2015-07-24 07:36:03
One thing I think they also introduced are the asp-controller and asp-action attributes to specify which controller and method to call, like so:
<a asp-controller="Home" asp-action="Index" rel="nofollow">Home</a>
I assume you can remove the use of strings here and instead use the
nameof()
operator like you did in theActionLink
.One thing that just clicked in my mind: would
nameof(HomeController)
returnHome
and notHomeController
? Where did it get the name from? Or was it determined out of (MVC route) convention?
That's correct. You need to do something like:
nameof(HomeController).SubString(0, nameof(HomeController).Length - 10);
You can create a quick HTML helper for this or a tag helper in MVC 6.
https://rehansaeed.com/c-6-0-saving-developers-from-themselves/