Click here to Skip to main content
15,885,757 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Schrodinger's pet Pin
David O'Neil16-Mar-21 18:41
professionalDavid O'Neil16-Mar-21 18:41 
GeneralRe: Schrodinger's pet Pin
obermd17-Mar-21 3:49
obermd17-Mar-21 3:49 
GeneralThought of the Day Pin
OriginalGriff16-Mar-21 5:46
mveOriginalGriff16-Mar-21 5:46 
GeneralRe: Thought of the Day Pin
W Balboos, GHB16-Mar-21 6:24
W Balboos, GHB16-Mar-21 6:24 
JokeRe: Thought of the Day Pin
Daniel Pfeffer16-Mar-21 7:58
professionalDaniel Pfeffer16-Mar-21 7:58 
GeneralWSO CC OTD 2021-03-16 : Solution Pin
Sandeep Mewara16-Mar-21 5:40
mveSandeep Mewara16-Mar-21 5:40 
GeneralRe: WSO CC OTD 2021-03-16 : Solution Pin
pkfox16-Mar-21 6:51
professionalpkfox16-Mar-21 6:51 
GeneralNice one, Visual Studio... Pin
Sander Rossel16-Mar-21 4:40
professionalSander Rossel16-Mar-21 4:40 
So I wrote this extension method for IUrlHelper, simply because it's available and my extension has to do with URL's.
For those interested:
C#
public static string Page(this IUrlHelper urlHelper, Type pageModelType)
    => pageModelType.Name.Replace("Model", string.Empty);
Which allows me to do:
Razor
<a class="btn btn-success" asp-page="@Url.Page(typeof(WhateverModel))">
Meaning, make an anchor tag with a URL that points to that page, even if I rename the page or move it or whatever.
It probably breaks if my page is in an(other) area, which hasn't happened, but at least I get some strong typing while still keeping to naming conventions (which in Razor Pages is that mysite.com/Whatever routes to WhateverModel).

Now the issue is that I don't actually use the IUrlHelper, so VS is giving me a warning to remove the unused variable.
As a fix, it suggests I add a SuppressMessageAttribute, which suppresses the message for that specific method.
However... Once I have the SuppressMessageAttribute, VS finds nothing to suppress anymore and I get a warning to remove the unnecessary SuppressMessageAttribute Dead | X|
It seems as though this only happens when I restart VS though, because when I remove and re-add the attribute the warning does not return.
Cool "feature" Roll eyes | :rolleyes:

GeneralRe: Nice one, Visual Studio... Pin
Kornfeld Eliyahu Peter16-Mar-21 4:58
professionalKornfeld Eliyahu Peter16-Mar-21 4:58 
GeneralRe: Nice one, Visual Studio... Pin
lmoelleb16-Mar-21 5:15
lmoelleb16-Mar-21 5:15 
RantBananas are radioactive: Now I am scared! Pin
Cp-Coder16-Mar-21 4:28
Cp-Coder16-Mar-21 4:28 
GeneralRe: Bananas are radioactive: Now I am scared! Pin
Maximilien16-Mar-21 4:31
Maximilien16-Mar-21 4:31 
GeneralRe: Bananas are radioactive: Now I am scared! Pin
Rage16-Mar-21 6:49
professionalRage16-Mar-21 6:49 
GeneralRe: Bananas are radioactive: Now I am scared! Pin
Sander Rossel16-Mar-21 4:54
professionalSander Rossel16-Mar-21 4:54 
GeneralRe: Bananas are radioactive: Now I am scared! Pin
Richard MacCutchan16-Mar-21 5:06
mveRichard MacCutchan16-Mar-21 5:06 
JokeRe: Bananas are radioactive: Now I am scared! PinPopular
Sander Rossel16-Mar-21 5:28
professionalSander Rossel16-Mar-21 5:28 
GeneralRe: Bananas are radioactive: Now I am scared! Pin
Richard MacCutchan16-Mar-21 6:56
mveRichard MacCutchan16-Mar-21 6:56 
GeneralRe: Bananas are radioactive: Now I am scared! Pin
Cp-Coder16-Mar-21 7:05
Cp-Coder16-Mar-21 7:05 
GeneralRe: Bananas are radioactive: Now I am scared! Pin
Richard MacCutchan16-Mar-21 7:23
mveRichard MacCutchan16-Mar-21 7:23 
GeneralRe: Bananas are radioactive: Now I am scared! Pin
Cp-Coder16-Mar-21 7:33
Cp-Coder16-Mar-21 7:33 
GeneralRe: Bananas are radioactive: Now I am scared! Pin
Richard MacCutchan16-Mar-21 7:48
mveRichard MacCutchan16-Mar-21 7:48 
GeneralRe: Bananas are radioactive: Now I am scared! Pin
Daniel Pfeffer16-Mar-21 8:07
professionalDaniel Pfeffer16-Mar-21 8:07 
GeneralRe: Bananas are radioactive: Now I am scared! Pin
W Balboos, GHB16-Mar-21 8:02
W Balboos, GHB16-Mar-21 8:02 
GeneralRe: Bananas are radioactive: Now I am scared! Pin
Richard MacCutchan16-Mar-21 22:36
mveRichard MacCutchan16-Mar-21 22:36 
GeneralRe: Bananas are radioactive: Now I am scared! Pin
W Balboos, GHB17-Mar-21 1:18
W Balboos, GHB17-Mar-21 1:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.