Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Newf
Feb 14, 2006
I appreciate hacky sack on a much deeper level than you.
I'd like to know what gets spit out by Path.GetInvalidFileNameChars(). Is there a more reasonable thing for me to do than boot up a new console app and print them to screen? I feel like Visual Studio should have some sort of console that I can type commands like this into.

Adbot
ADBOT LOVES YOU

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy

Newf posted:

I'd like to know what gets spit out by Path.GetInvalidFileNameChars(). Is there a more reasonable thing for me to do than boot up a new console app and print them to screen? I feel like Visual Studio should have some sort of console that I can type commands like this into.

Unfortunately there's not an easily accessible C# REPL yet. You could use the F# interactive console in Visual Studio:

code:
> open System.IO;;
> Path.GetInvalidFileNameChars();;
val it : char [] =
  [|'"'; '<'; '>'; '|'; '\000'; '\001'; '\002'; '\003'; '\004'; '\005'; '\006';
    '\007'; '\b'; '\009'; '\010'; '\011'; '\012'; '\013'; '\014'; '\015';
    '\016'; '\017'; '\018'; '\019'; '\020'; '\021'; '\022'; '\023'; '\024';
    '\025'; '\026'; '\027'; '\028'; '\029'; '\030'; '\031'; ':'; '*'; '?';
    '\\'; '/'|]

Newf
Feb 14, 2006
I appreciate hacky sack on a much deeper level than you.
That's great! Thanks!

Ctrl+alt+F opens this console in VS 2010 and up, for anyone who's wondering.


My knowledge of F# has now increased from nothing to "it's like C# except you use two semicolons". I'm confident that this is accurate.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Newf posted:

My knowledge of F# has now increased from nothing to "it's like C# except you use two semicolons". I'm confident that this is accurate.

This is entirely inaccurate.

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy
Congratulations, you now know functional programming!

Nevett
Aug 31, 2001

Newf posted:

I'd like to know what gets spit out by Path.GetInvalidFileNameChars(). Is there a more reasonable thing for me to do than boot up a new console app and print them to screen? I feel like Visual Studio should have some sort of console that I can type commands like this into.

Get LINQPad! The free version will let you do this (and almost everything else except intellisense)

Don't let the name fool you, it's great as a general code scratchpad.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Nevett posted:

Get LINQPad! The free version will let you do this (and almost everything else except intellisense)

Don't let the name fool you, it's great as a general code scratchpad.



Or just use Powershell, which is already installed on every modern version of Windows. Syntax is a bit different, but it's easy to learn:

[System.IO.Path]::GetInvalidFilenameChars()

Factor Mystic
Mar 20, 2006

Baby's First Post-Apocalyptic Fiction

Bognar posted:

Unfortunately there's not an easily accessible C# REPL yet. You could use the F# interactive console in Visual Studio:


What? There's no need to use the F# console. This is basically what the Immediate Window is for, but you do have to be debugging.

ljw1004
Jan 18, 2005

rum

Factor Mystic posted:

What? There's no need to use the F# console. This is basically what the Immediate Window is for, but you do have to be debugging.

That's not true! You can use the Immediate Window "immediately" without debugging...

(1) Launch VS. You have to load a project -- any old project will do.

(2) Debug>Windows>Immediate (or use its shortcut Ctrl+G)

(3) type in your expression, e.g. "? System.IO.Path.GetInvalidFileNameChars()"



Note: under the hood, it automatically builds your project and runs the immediate window against your project, so yes technically speaking it us debugging you just don't notice it. What this means is that, if you had defined any methods or types in your project, then you can call them from the immediate window. For instance, define "class C {}" in your code, and then try writing "? new C()".

Newf
Feb 14, 2006
I appreciate hacky sack on a much deeper level than you.
All very useful suggestions. Thanks!

ljw1004 posted:

(1) Launch VS. You have to load a project -- any old project will do.

Not quite, I'm afraid! Apparently:

msdn posted:

You cannot use design time expression evaluation in project types that require starting up an execution environment, including Visual Studio Tools for Office projects, Web projects, Smart Device projects, and SQL projects.

Sedro
Dec 31, 2008

Newf posted:

I'd like to know what gets spit out by Path.GetInvalidFileNameChars(). Is there a more reasonable thing for me to do than boot up a new console app and print them to screen? I feel like Visual Studio should have some sort of console that I can type commands like this into.
If you already have something running in a debugger you can use the "Immediate" window. You can't use lambda expressions though which makes it useless 90% of the time.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug
Does anyone have any good resources for how to build a modern SPA that leverages MVC5/WebAPI and SignalR and whatever JS frameworks are hot right now? I haven't done any webdev in the past few years, and I really want to put something modern together to keep my skills sharp.

Part of the fun is that I'm absolutely terrible at HTML and CSS. I have to resist the urge to use tables for layout.

Adahn the nameless
Jul 12, 2006

Ithaqua posted:

Does anyone have any good resources for how to build a modern SPA that leverages MVC5/WebAPI and SignalR and whatever JS frameworks are hot right now? I haven't done any webdev in the past few years, and I really want to put something modern together to keep my skills sharp.

Part of the fun is that I'm absolutely terrible at HTML and CSS. I have to resist the urge to use tables for layout.

As far as layout goes, I'd recommend using a css framework. Bootstrap, foundation, something like that. At the bare minimum, a fluid grid. If you want a really nice resume project, I'm sure you could find a $30 theme from https://wrapbootstrap.com/ to really impress people.

Newf
Feb 14, 2006
I appreciate hacky sack on a much deeper level than you.
I'll second that. I'm a complete rear end whenever it comes to deciding things like typography and colors, but I'm currently having a good deal of success with a work project that I essentially threw a Bootstrap tarp over the top of.

gnatalie
Jul 1, 2003

blasting women into space
I've had decent luck with John Papa's SPA / Visual studio template

There's an associated Pluralsight video with it but I haven't had a chance to watch it.

Fuck them
Jan 21, 2011

and their bullshit
:yotj:
So I just wasted time making a .asmx service trying to fit with the rest of this poo poo old website and got sick of my json being wrapped in a single XML String, even with json.NET and such. And everything I could imagine to change the web config. gently caress it.

I basically want to have a searchable, jQuery datatables type Table that shows results from about ~1200 total rows of a DB which come down to "metadata about admin orders and a file path to a scan of the Judge's order bla bla bla." Do I want a WCF data service or a WCF service? Is there even a real difference? I was assuming just fork over the entire table and search/paginate, but I've also seen tutorials where every time someone changes the search string it actually queries the DB every time and sends the results. Maybe it's how green I am but it seems like if the list of rows is that low you'd be better off just sending it all once at page load, especially if it's an intranet app.

I have total freedom with what I'm setting out to do and picked jQuery from familiarity. Is there any reason to instead do the .NET gridview (or whatever) instead?

Dr. Poz
Sep 8, 2003

Dr. Poz just diagnosed you with a serious case of being a pussy. Now get back out there and hit them till you can't remember your kid's name.

Pillbug

Ithaqua posted:

Does anyone have any good resources for how to build a modern SPA that leverages MVC5/WebAPI and SignalR and whatever JS frameworks are hot right now? I haven't done any webdev in the past few years, and I really want to put something modern together to keep my skills sharp.

Part of the fun is that I'm absolutely terrible at HTML and CSS. I have to resist the urge to use tables for layout.

Mads Kristensen did a presentation along these lines at this years TechEd. I haven't watched this one in particular but it seems to match your general description. Link

Fuck them
Jan 21, 2011

and their bullshit
:yotj:

Ithaqua posted:

Part of the fun is that I'm absolutely terrible at HTML and CSS. I have to resist the urge to use tables for layout.

LESS is your friend and so is bootstrap. I still hate it but bootstrap layouts helped immensely and LESS helps you cut down on the CSS poo poo.

Then again I also basically had to spend a month cleaning up my project's 5 cooks spoiling the soup and just had to deal with it.

I hate web poo poo. But all I do is web poo poo.

wwb
Aug 17, 2004

nthing bootstrap -- it is a great and well documented framework (http://getbootstrap.com/getting-started/).

For the javascript framework I would probably go with Angular as it is quite well documented and it just makes sense more than the others. It is also popular with the .NET crowd so there is plenty of material out there about using it within .NET. Note that they are working on 2.0 which is a significant departure from 1.x so you might want to dive in on that side if this is future facing.

gently caress them posted:

So I just wasted time making a .asmx service trying to fit with the rest of this poo poo old website and got sick of my json being wrapped in a single XML String, even with json.NET and such. And everything I could imagine to change the web config. gently caress it.

I basically want to have a searchable, jQuery datatables type Table that shows results from about ~1200 total rows of a DB which come down to "metadata about admin orders and a file path to a scan of the Judge's order bla bla bla." Do I want a WCF data service or a WCF service? Is there even a real difference? I was assuming just fork over the entire table and search/paginate, but I've also seen tutorials where every time someone changes the search string it actually queries the DB every time and sends the results. Maybe it's how green I am but it seems like if the list of rows is that low you'd be better off just sending it all once at page load, especially if it's an intranet app.

I have total freedom with what I'm setting out to do and picked jQuery from familiarity. Is there any reason to instead do the .NET gridview (or whatever) instead?

1200 rows is a lot of data in internet ui terms, I would definitely want to filter that on the server side. If it is read only and I was stuck in an old project I would strongly consider just wiring up an asp.net handler and spitting out json based on the query string rather than bothering with any wcf hoo-ha.

RICHUNCLEPENNYBAGS
Dec 21, 2010
I would swear there was an easy way to do this. Isn't there a way to go from a lambda to the full, written out expression (in other words, creating expressions by explicitly calling Expression.whatever)? Sometimes I feel like it would be helpful when trying to do things with expressions if I could just write out simple examples and look at the results.

Opulent Ceremony
Feb 22, 2012

gently caress them posted:

I basically want to have a searchable, jQuery datatables type Table that shows results from about ~1200 total rows of a DB which come down to "metadata about admin orders and a file path to a scan of the Judge's order bla bla bla." Do I want a WCF data service or a WCF service? Is there even a real difference? I was assuming just fork over the entire table and search/paginate, but I've also seen tutorials where every time someone changes the search string it actually queries the DB every time and sends the results. Maybe it's how green I am but it seems like if the list of rows is that low you'd be better off just sending it all once at page load, especially if it's an intranet app.

If you are using jQ Datatables you can choose to load partially from the server (and send a new request each time the user changes some filter) or load it in its entirety at once and let jQDT do all of the paging and filtering client-side. I think 'bServerSide' is the option during the initialization that determines this.

If you choose to let jQDT load all the data at once and filter client-side, you can also override and extend the built-in filtering via their API as well.

Sedro
Dec 31, 2008

RICHUNCLEPENNYBAGS posted:

I would swear there was an easy way to do this. Isn't there a way to go from a lambda to the full, written out expression (in other words, creating expressions by explicitly calling Expression.whatever)? Sometimes I feel like it would be helpful when trying to do things with expressions if I could just write out simple examples and look at the results.
It's an implicit conversion provided by the language. The compiler will generate the expression tree.
C# code:
Expression<Func<string, int>> expr = s => s.Length;

RICHUNCLEPENNYBAGS
Dec 21, 2010

Sedro posted:

It's an implicit conversion provided by the language. The compiler will generate the expression tree.
C# code:
Expression<Func<string, int>> expr = s => s.Length;

Yes, I know that. But that doesn't help me do things like visit expressions, modify them, etc. So what I would like to see is the equivalent, long-way-round code. I think maybe you can do this by compiling and then decompiling with the decompiler set to a lower version of .NET or something like that.

chippy
Aug 16, 2006

OK I DON'T GET IT

RICHUNCLEPENNYBAGS posted:

Yes, I know that. But that doesn't help me do things like visit expressions, modify them, etc. So what I would like to see is the equivalent, long-way-round code. I think maybe you can do this by compiling and then decompiling with the decompiler set to a lower version of .NET or something like that.

Is this what you need?

http://msdn.microsoft.com/en-us/library/bb397951.aspx

Fuck them
Jan 21, 2011

and their bullshit
:yotj:
Just what exactly are ALL of the places one can change how requests are returned in .NET? I've gone through every single decorator I can find for my methods in .svc and .asmx and .whatever files, and I want to return JSON, and I keep either returning a single XML string which itself contains JSON, or I return JSON in a SOAP envelope.

Is there something in web.config I've overlooked? I've scoured MDSN, stack overflow, google, and even tried restarting VS a few times, and it's getting very frustrating.

I just want to spit out a JSON string :(

RICHUNCLEPENNYBAGS
Dec 21, 2010

gently caress them posted:

Just what exactly are ALL of the places one can change how requests are returned in .NET? I've gone through every single decorator I can find for my methods in .svc and .asmx and .whatever files, and I want to return JSON, and I keep either returning a single XML string which itself contains JSON, or I return JSON in a SOAP envelope.

Is there something in web.config I've overlooked? I've scoured MDSN, stack overflow, google, and even tried restarting VS a few times, and it's getting very frustrating.

I just want to spit out a JSON string :(

Why can't you just return a JsonResult? Or use Content if it's already a JSON string?

Also you should probably be more specific about what you're trying to do since here I am giving you an MVC answer but you've not mentioned at all what kind of application it is so it may very well be irrelevant. Your question is kind of ill-formed ("anywhere" if you don't specify the library).

RICHUNCLEPENNYBAGS fucked around with this message at 06:00 on Jul 27, 2014

gariig
Dec 31, 2004
Beaten into submission by my fiance
Pillbug

gently caress them posted:

Just what exactly are ALL of the places one can change how requests are returned in .NET? I've gone through every single decorator I can find for my methods in .svc and .asmx and .whatever files, and I want to return JSON, and I keep either returning a single XML string which itself contains JSON, or I return JSON in a SOAP envelope.

Is there something in web.config I've overlooked? I've scoured MDSN, stack overflow, google, and even tried restarting VS a few times, and it's getting very frustrating.

I just want to spit out a JSON string :(

Stop using ASMX. It's really freaking old. If you are starting fresh today you want to use Web API. That's the easiest way to send json or XML over HTTP to a client. If you can't use Web API use WCF.

Fuck them
Jan 21, 2011

and their bullshit
:yotj:

RICHUNCLEPENNYBAGS posted:

Why can't you just return a JsonResult? Or use Content if it's already a JSON string?

Also you should probably be more specific about what you're trying to do since here I am giving you an MVC answer but you've not mentioned at all what kind of application it is so it may very well be irrelevant. Your question is kind of ill-formed ("anywhere" if you don't specify the library).

I was working within an asp.net forms template that basically underpins the rest of the project. It wasn't fun. I had gone through MSDN/Stack Overflow/Google writ large trying to figure it out and it was basically just configuration and decoration voodoo.

gariig posted:

Stop using ASMX. It's really freaking old. If you are starting fresh today you want to use Web API. That's the easiest way to send json or XML over HTTP to a client. If you can't use Web API use WCF.

I tried with WCF and I kept getting everything wrapped up in a SOAP envelope.


On monday (or tomorrow if I get bored) I'm going to just use WebAPI. My last job was MVC (WOO!) and I could just burp up my JSON from my controllers and it was all pretty awesome. Trying to work with all this old poo poo the way it was done is pretty crappy. At least I can say I tried.

My Senior Dev hasn't ever done MVC :wtc: so I figured "welp ok why not learn a little old school poo poo" and it really wasn't a great idea.

Blinkz0rz
May 27, 2001

MY CONTEMPT FOR MY OWN EMPLOYEES IS ONLY MATCHED BY MY LOVE FOR TOM BRADY'S SWEATY MAGA BALLS
So I'm using ReactiveUI to build a WPF application and I'm stumped. I'm trying to link the selected value of a listview to an observable property and then trigger a ReactiveCommand.

How do I do this? Reactive's docs are lacking, to say the least.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug
Just wanted to thank everyone for the web app advice. I ended up saying "gently caress it" and starting out with just MVC, jQuery, and SignalR. I hacked a tech demo together last night, then spent today redoing it using knockout because the JS was turning into a big mess of random DOM manipulation. I'll probably revisit everything with bootstrap when I have some free time, since the HTML is pretty hideous. Then I can actually start building real functionality!

ShaunO
Jan 29, 2006

Ithaqua posted:

Just wanted to thank everyone for the web app advice. I ended up saying "gently caress it" and starting out with just MVC, jQuery, and SignalR. I hacked a tech demo together last night, then spent today redoing it using knockout because the JS was turning into a big mess of random DOM manipulation. I'll probably revisit everything with bootstrap when I have some free time, since the HTML is pretty hideous. Then I can actually start building real functionality!

Please try react at some point, I threw knockout in the bin because its performance is poo poo in comparison and I feel code written with knockout isn't very reusable
It's a whole different ballgame in terms of tooling and you'll probably end up in the npm world and using a different editor for jsx source files but I'm so glad I went down that path. The component based architecture is so much better than the knockout/angular data binding style IMO

Adahn the nameless
Jul 12, 2006

ShaunO posted:

Please try react at some point, I threw knockout in the bin because its performance is poo poo in comparison and I feel code written with knockout isn't very reusable
It's a whole different ballgame in terms of tooling and you'll probably end up in the npm world and using a different editor for jsx source files but I'm so glad I went down that path. The component based architecture is so much better than the knockout/angular data binding style IMO

This is truth. React is awesome. Best of the lot, I think.

The only caveat is that if you're looking for resume fodder, react doesn't seem to me to be too popular in the .Net community.

Bognar
Aug 4, 2011

I am the queen of France
Hot Rope Guy
Chiming in here about the awesomeness of React. It's a breath of fresh air in the poo poo-filled world of frontend JS frameworks. The .NET shop I work at has picked it up for a few things and is absolutely loving it. My biggest gripe, however, is the complete lack of syntax support (even through plugins) in Visual Studio for JSX.

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug
Neat, I'll check out react when I have some time! Knockout is serving my purposes well enough; it's close enough to XAML databinding that it doesn't hurt my brain too much.

Fuck them
Jan 21, 2011

and their bullshit
:yotj:
I finally just used WebAPI for my JSON needs and I should have done this in the first place. Holy crap this is better.

wwb
Aug 17, 2004

Ithaqua posted:

Neat, I'll check out react when I have some time! Knockout is serving my purposes well enough; it's close enough to XAML databinding that it doesn't hurt my brain too much.

This is why one should not use knockout if one is trying to learn web stuff. Knockout is great but the user base is pretty much recovering wpf/silverlight dudes and some extension into .NET only devs. It don't get much pickup outside of the .NET world.

Fuck them
Jan 21, 2011

and their bullshit
:yotj:
This is going to be one of those drat weeks, I can feel it.

I have a webapi project and an asp.net forms template in the same solution.

Despite setting both to start at the same time and having the webapi project referenced in the website I can't actually call the controller from the webapi project.

I can however copy and paste the paths with port numbers and just get the json right into my browser.

Malcolm XML
Aug 8, 2009

I always knew it would end like this.

wwb posted:

This is why one should not use knockout if one is trying to learn web stuff. Knockout is great but the user base is pretty much recovering wpf/silverlight dudes and some extension into .NET only devs. It don't get much pickup outside of the .NET world.

that said MVVM is very good at solving a very common pattern

I suspect you could use react with knockout.

Drastic Actions
Apr 7, 2009

FUCK YOU!
GET PUMPED!
Nap Ghost

gently caress them posted:

This is going to be one of those drat weeks, I can feel it.

I have a webapi project and an asp.net forms template in the same solution.

Despite setting both to start at the same time and having the webapi project referenced in the website I can't actually call the controller from the webapi project.

I can however copy and paste the paths with port numbers and just get the json right into my browser.

I don't use WebAPI much, so I may be misunderstanding how it works, but why would you call the controller directly from the API? The controller calls the API, requests for something, and the API returns the data to whoever called it. The API should not know anything about the controllers.

Adbot
ADBOT LOVES YOU

Fuck them
Jan 21, 2011

and their bullshit
:yotj:

Drastic Actions posted:

I don't use WebAPI much, so I may be misunderstanding how it works, but why would you call the controller directly from the API? The controller calls the API, requests for something, and the API returns the data to whoever called it. The API should not know anything about the controllers.

I wanted for some javascript (jquery datatables) on my page to be able to call /api/controllername and get json from it.

I meant to say the webapi project's controller object isn't something I can reference from my web page. The two separate projects didn't work. Trying to do it all in one project didn't work.

But since I'm apparently trying to learn about 5 different ways of doing something on asp since I'm working alone and trying to take my MVC knowledge and match it with this workplace's old-hat asp stuff and it's making me mash my face as flat as a pug while the only other programmer here comes and goes like a drat housecat I'm just going to copy/paste from a tutorial until I get my poo poo working then do tutorials to look busy.

What really kills me is I'm allowed to waste so much time here. There's no accountability and I'm not really sure a year from now me (or a few years from now me) would want me to spend the time to learn how to do poo poo from 2003.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply