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
wwb
Aug 17, 2004

I would avoid hand building XML like the plague. If you need to build it iteratively I'd take a hard look at using xml text writer -- you will create invalid XML at some point.

As for the OP, there really should be some other SCM options. Here is my rewrite:

quote:

Should I be using source control?
Yes! Here are some options to get you started:

* TFS, which isn't as lovely as it used to be but nobody uses outside of the narrow Microsoft bubble, is now free for 5 users at Visual Studio Online.
* Git, which all the cool kids use, has native visual studio integration that works pretty good for simple operations. If you can't hack the command line you can use SourceTree or TortoiseGit. For git hosting check out github, where the cool kids hang and share their codes, or bitbucket where you get unlimited free private repos for less than 5 users.
* Mercurial is another DCVS that isn't as cool as git but can still git er done and is a bit more user- and windows-friendly. You can get gui clients using SourceTree or TortoiseHG. Visual studio integration can be had using the VisualHg plugin.
* If you just can bring yourself to use a modern DCVS fear not -- Subversion still exists and works pretty well for simple workflows. You can stand up a SVN server on windows rather painlessly using VisualSVN server. For client activities you are going to want TortoiseSVN which will work with VisualSVN in visual studio for a pretty seamless experience.

Adbot
ADBOT LOVES YOU

wwb
Aug 17, 2004

Ithaqua posted:

Thanks, I'll update the OP tonight. I was focusing on Microsoft tooling because this is the catch-all Microsoft development thread.

Come to think of it, I'll add a build and release section while I'm at it, and a cloud section.

Sounds good. I contemplated tacking a CI section on but I thought that was a bit beyond scope. Lots of interesting cloud options popping up.

The other thing I think we are missing is a bit more flesh on the xarminian / non-MS platform stuff. Especially now that Nardella has made that a 1st class citizen in the ecosystem.

quote:

big xml dumping issues

A bit late to the party but why not use an XmlTextWriter -- that will let you guarantee well formedness while also letting you stream the results quickly.

PS: for content -- actually have a greenfield project. Basically a CMS feeding a web API that will feed lots of other stuff. Looking at options for IoC containers it seems like the cool kids like autofac whereas we've been a structuremap shop for a while. Any good reason to make the switch? And any other shiny new toys we should look at while I'm at it?

wwb fucked around with this message at 22:44 on Jun 27, 2014

wwb
Aug 17, 2004

Thanks for updating the OP -- any way we could get the links to TortoiseHG / TortoiseSVN as well as bitbucket back in there?

wwb
Aug 17, 2004

Yes, they are vastly different beyond some surface similarities as to similar languages. Especially with Option Strict on. The best place to start is http://www.asp.net/get-started , that is probably one of the few sites still doing examples in VB.Net though -- most of the world has gone C#. You might wish to do the same.

wwb
Aug 17, 2004

You know I did manage to read that backwards.

I will note you can make very maintainable code in lovely old languages too, it just requires more discipline. And I've seen a boat load of ASP.NET apps with "presentation and business logic mushed together in one place"; arguably more so than in other frameworks that don't give you as many wizards to generate code.

wwb
Aug 17, 2004

I will publicly admit I came out in the "I hate var" school when it came out but have since learned to appreciate it. As a great man pointed out, perhaps in this thread, it is really the IDE's problem to figure out what type you are dealing with and it works brilliantly. Our rule here has become "just use var unless you can't use var" over the last few years.

Newf posted:

It's perhaps not clear, but I am in a databound control (note that the first <%# Eval("States.Length") %> works). The problem is that the control is bound to an object which has a number of arrays as members, including the present States array.

The solution then, I guess, is to bind more specifically to the States array rather than its parent object.

You have a few issues in this code. First thing, don't try and convert int to strings and then do int things to them (error #1). Response.Write() is also an abomination that should generally be avoided in ASP.NET webforms as it really screws with the page lifecycle.

In general, with complex data binding, you are better off convervting the Container.DataItem to your custom object and never loving using eval no Response.Write. Something like:

code:
<ItemTemplate>

<%
    var di = Container.DataItem as MyClass
%>

Length is di.States.Length %>

<%

 int length = di.States.Length
 
 for (int i=0; i<length; i++)
 {
    %>
	<li><%# di.States[i] #%>
%>
 }

%>

</ItemTemplate>
Been a really long time since I did webforms so that might not be perfectly kosher but you get the idea.

wwb
Aug 17, 2004

More like ASP.NET takes the template file and generates a C# class that inherits from your page class and basically spits out a string at the end of the day. If you want to look under the hood, look at the next exception you get -- somewhere near the bottom of the page it will tell you the source file name, open it in your favorite text editor.

wwb
Aug 17, 2004

Even if you are stuck on 2010 then you can defintiely use MVC4, which isn't the absolute latest and greatest but it is a decent snapshot of the point where most of the warts are worked out.

You can build stuff distrubingly quick -- with a little tweaking of datavalidation attributes and EditorFor you can beet webforms speed to market in terms of building CRUD apps. UI look and feel is pretty easy now that they have gone all twitter bootstrap on you. Moreover, it is something you probably want on the resume rather than web forms. Unless you enjoy maintaining dead-end legacy applications.

wwb
Aug 17, 2004

Ran headlong into a windows thing that someone here might have ran into -- it seems that Visual Studio 2013 installed HyperV with Update 2 because of windows phone. Unfortunately hyperv breaks networking on VirtualBox and I need that function a lot more than I need to be able to emulate windows phone. Anyhow, I didn't figure this out until after I tried to upgrade virtualbox and ended up with a bunch of screweyness in the network stack somewhereas I can't seem to uninstall or reinstall it. Moreover, I can't remove hyperv at all -- I can uncheck the box, it runs the uninstall, reboots and then hangs at about 36% before rolling back my changes. I've looked in a few of the obvious places but I haven't found any rhyme or reason to this, is there some other tree I should bark up? Or has anyone run into this at all -- everything from google seems to be about people having problems installing hyperv not removing it.

wwb
Aug 17, 2004

I failed to mention but yes, I did uninstall virtualbox to eliminate that variable. Though I didn't do more than the uninstall so that might be a good tree to bark up.

For content: VSO is offline right now: http://blogs.msdn.com/b/vsoservice/archive/2014/07/18/vso-services-are-unavailable-7-18-investigating.aspx; wonder how much the shops that are using TFS in the cloud are doing . . .

wwb fucked around with this message at 16:23 on Jul 18, 2014

wwb
Aug 17, 2004

Dr. Poz posted:

I've run into this before as well but I was able to resolve it by turning off Hyper-V in the Add/Remove Windows Features section of Programs. You're saying that when you do that it goes through the motions of uninstalling it but then hangs and rolls back?

Unchecking the box in that screen is exactly what I'm doing and it isn't being too successful.

I just tried the manual virtualbox cleanup and I'm sitting here watching the hyper-v uninstall hang at 36% again. In about 40 minutes whatever it is will finally timeout and it will reboot again and rollback the change. At this point if I had started the windows reinstall when this popped up I'd be done by now with most of a working stack on the box . . .

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.

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.

wwb
Aug 17, 2004

nthing the "build offline services" suggestion -- that really is the way to fly. Been through similar re-wrapping of POCO stuff several times, works great.

Like I previously said, if this is a HTTP GET-only "read this data" thing embedded in a legacy project then you can every easily use a straight .ashx handler here on legacy versions of .NET. IHttpHandlers are the basic building block of the .NET web pipeline, at least the legacy bit. It gets you down to "given a request to this url spit back this data".

How to get there is pretty easy -- just add a new generic http handler to the project, do stuff in the process request method it gives you.

wwb
Aug 17, 2004

Knyteguy posted:

How do you guys save little reusable blurbs of code to use through various projects? A class library would work with static methods but that seems like a pain to maintain. Does VS have something like this built in?

I would blog about it but that would require having a blog.

We just statically include the code in projects in general here if it is just little utility functions. We've been down the path of a standard library and it ends up getting bloated and fugly fast. You also take on versionsing issues as oftentimes things need slightly different implementations. Add to that the ease of debugging statically included code versus a library and the decision is easy.

Nuget makes one think it would be easy to manage the external dependency and that is true -- at least for stuff that grows from "random function" to "small library" -- but it really does not solve the versioning issue. Keeping snippets in a repo makes sense though, for the most part we just go grab the code of the the other project to start with and modify from there.

wwb
Aug 17, 2004

Che Delilas posted:

I'm trying to learn MVC for a personal project and to expand my skillset in general, and this Identity poo poo is not making it easy, let me tell you.


Meanwhile, it provides a DatePicker but not a DateTimePicker, because why would you have a control that takes advantage of a built-in data type (DateTime) when you can have one that takes advantage of only half of it? I mean, nobody cares about time of day, right? Especially in a business environment.

We got a meeting tomorrow guys. What time? Tomorrow. Something wrong with your ears?

I'm not having that big of a problem with the new identity bits. In fact they make quite a bit more sense than fighting through the old identity providers. Especially on the custom implementation side. I'd generally argue that they leave a bit to be desired -- the API surface is basically designed around "what do we need to work with Active Directory? And what do we need to make *our* MSSQL-based provider work to look like active directory?" But I'd take identity over membership most days of the week.

As for the datepicker our old rule when we used web forms was "any microsoft provided control beyond your very basic repeaters, text boxes, check boxes and the like is really for MS to have roadshows to sell that poo poo to managers." Most of them were useless beyond the demo case to be sure.

wwb
Aug 17, 2004

In general my experience has been one is best left leaving the authentication bits as a functional black box and then keeping your app's data (like demographic / address info) in data stores tied to my app. We typically go so far as to keep that asp.net databases as a physically separate DB as we don't like schlepping user logins back to developers.

That said, the new extensibility points in the Identity bits should make extending stuff to use a custom user with this info is much easier than what one had to do with the old membership providers. But I still don't like mixing the two myself.

wwb
Aug 17, 2004

RICHUNCLEPENNYBAGS posted:

There's no reason at all to avoid adding fields to your ApplicationUser class/subclassing it/whatever. Especially if you're using the EF Code First Identity and EF Code First in your application. Nothing to it.

If it were me I'd make Address a class and give ApplicationUser an Address field.

Yeah, it is fun and easy and you probably won't have as retarded a data schema as one would by extending membership. It still don't make it right to mix authentication and application data though, keep them separate. Your future self will thank you for it.

wwb
Aug 17, 2004

Measure what the cost is -- you'd be shocked at how efficent modern stuff is. 99% of the time you can make zero real-world performance gains on the back end of your website that are measurable compared to things you can do on the front end like edge caching and compression. My 2c is the best going in proposition is to leave caching for anything longer than a single request until you have measurable performance gains you can get by caching it.

That said the key thing to think about is how long is the object life cycle? And how mutable are things? IE we have configuration objects that get hydrated on start and don't mutate and you can cache the living poo poo out of them. But anything violate is a bitch to cache, or really requires a cache invalidation strategy.

If you are really depending on the object to be there don't use ASP.NET's cache. At least the .NET 2.0 implementation would start ejecting things at the first sign of memory trouble. If you did something really retarded like have a cache callback to re-cache an object on ejection you got nasty loops. It really was written to be an output cache for the pages not a memcached equivalent.

wwb
Aug 17, 2004

Dr. Poz posted:

Mvc Question

My action method takes an int but if a jerk types in a string they get send to a runtime error page. I'd much rather send them to an error page of my design. What's the best way to handle parameter validation of this fashion for action methods?

Better way is to handle it in routing and constrain your routes rather than just take defaults. At least for public-facing web apps. With attribute routing this is really fun and easy now.

wwb
Aug 17, 2004

Not as awesome as fluentvalidation.

But they are nice.

wwb
Aug 17, 2004

comedyblissoption posted:

Does anyone have a recommendation for a resource for learning F# for someone pretty familiar with C#?

I'd start with http://www.manning.com/petricek/ -- has parallel examples, and there are lots of tricks you can take back to your existing C# codebase from it.

wwb
Aug 17, 2004

Fundamentally the point of .ToString() is to make sure you can call .ToString() on any object. Having the type name spit out is a reasonable behavior and gives a bit more information than having it say "Fix Me".

If you call .ToString() on an int32 it will spit out the number. If you call it on the array it will spit out the fact it is a System.Int32[]. If you want to spit out the length perhaps you should call myarray.Length.ToString().

wwb
Aug 17, 2004

I'd admit defeat and look at the grunt option -- it really is the way forward and I suspect it will become more and more prevalent in ASP.NET as they move away from VS dependence.

I will admit that node seems like a funky dependency and there is a whole lot of stupid poo poo on the platform but there is some pretty cool or handy poo poo as well. Or at least grunt is pretty awesome -- having a pretty good build / integration tool for static stuff is pretty worthwhile. Karma -- a javascript unit testing framework -- is pretty sweet as well.

wwb
Aug 17, 2004

gently caress them posted:

code:
ef4 connection string
I just don't know why all this poo poo is packed up into the connection string.

Looks like you were using an earlier version of the EF when they needed a special connection string because they were stuck on using the designer and I guess a good old fasioned connection string isn't good enough. Anyhow, that isn't too complex -- just a typical connection string xml encoded. But it was a PITA and it is now gone.

PS: see http://odetocode.com/blogs/scott/archive/2014/08/14/c-6-0-features-part-ii-primary-constructors.aspx for stuff on C# 6 constructor parameters. I'm not sure how much they do for me given resharper has got it down to a few wacks of alt-enter.

wwb
Aug 17, 2004

None of this is beating resharper + alt-enter for me. All of it is a lot harder to read / follow.

Then again I'm a luddite at times.

wwb
Aug 17, 2004

RICHUNCLEPENNYBAGS posted:

Winforms isn't that bad if you have some discipline but you end up having to work with other people who put all the calculations in the freaking code-behind.

You can say the same thing about ASP.NET Webforms or WCF but that don't mean you should start projects built around them.

wwb
Aug 17, 2004

If it is basic "we want humans to do formatted text" we have gone with markdown, perhaps with a raw html saftey valve. Much, much cleaner to deal with than the poo poo the rich text editors spit out.

Another approach is to use some reverse proxy voodoo to poke holes in the CMS-based site for your app. If the parts are self-contained this works real good.

Another thing we are doing a lot of these days is building the custom bits as an mvc specialized content manager serving a web api and then handing the api off to the web hippies to integrate. The main challenge has been that the web hippies suck at specifying what they need to come off the API so you usually get to build that part 3 times. The massive advantage is we can let the web hippies use whatever they want to smoke that week without having to inhale.

wwb
Aug 17, 2004

If I need a structure complex enough to need json to deal with it I would start strongly considering POST. The big wall you can run into is max url length -- which can get set by intermediaries and security software as well as things you might be able to understand [browsers] and fix [server settings].

That said, for:

code:
/Search?term=pumas&filters={"productType":["Clothing","Bags"],"color":["Black","Red"]}
I would prefer:

code:
/Search?term=pumas&productType=Clothing&productType=Bags&color=Black&color=Red
This makes the url much more readable and you don't waste precious characters encoding json for no reason.

From the controller side, this will work with

code:
public ActionResult Search(string term, string[] productType, string[] color)
If you are working with the web API it will serialize out to a properly constructed object if you'd prefer. Not sure if that works on the MVC side though.

wwb
Aug 17, 2004

Absolutely -- no matter what data back end we are using (mainly ravendb these days, with some EF and micro orms as required) we keep it sequestered in some sort of data access service layer. The upper layers should not know about anything horribly database specific.

wwb
Aug 17, 2004

Funking Giblet posted:

I use NHibernates ISession directly in the controllers.

It's awesome!

Do you get paid by the hour?

wwb
Aug 17, 2004

Scaramouche posted:

Thanks for the replies guys; I think I either gave too much information or too little! If I was to break down my question into the abstract it'd be: "If I need to refer to a static series of values, is it better to have a database hit once and store the table in session, or should I make a database call every time? (keeping in mind that the table data doesn't change)"

I have to do this in real time because I'm parsing over 500,000 pieces of jewelry per day from EDI, csv, XML, our own database, etc. etc. In about 50% of the cases the AGTA information isn't included, so I have to make assumptions using the table. The application is not on the same server as the database, and the job is already so big it's chunked up by vendor, with each vendor taking about 40 minutes to process. This is why I'm trying not to introduce more time into the operation.

By doing it badly I mean typing out 140 if/then/else or case statements, even though the actual number of treatments is about 20 or so. In the short term I've done a database only solution last night, we'll see how it performs.

I'll just be contrarian here and note that while the concept of using a database makes a lot of sense you might not want an actual database server involved -- if it is just a key-value lookup then using a static Dictionary<string, GemInfo> isn't the most horrible thing in the world. Said "database" could be hydrated from an xml or json file which gets compiled in as a static resource. The key advantage here is that the app can travel with the data internally so you don't need to stand up the gem DB to do testing / developing. Downside is you've got a big object in memory but RAM is cheap these days.

wwb
Aug 17, 2004

I'm not sure if redis would help here -- you get the same, if not more, development friction by adding redis or adding a database. They are both external tools that need to be installed and configured.

mortarr posted:

Here's the stack trace.

It's bailing when called from an MVC app hosted in VS 2012, but not when called from a test project in the same solution run using testdriven.net. Same method, same arguments, same document I'm trying to extract pages from, but different result. In both cases I can extract pages 1-34, but not >=35 under MVC. The tiff does not appear to be malformed - I can open it in a variety of apps and see all its pages.

Doesn't seem to matter where the doc is on the filesystem, so probably not a permissions thing.

I'd add some debug statements to spit out data about the pdf like how many pages it sees. Not familiar with the underlying library but my guess is it does something that makes it behave different running inside IIS versus running in testdriven.net.

It also might be worth hooking it into full-blown IIS on said machine to see if that somehow makes a difference. To do so and get debugging just setup a virtual site pointed to the app and run VS as administrator and connect to the right w3wp.exe process.

wwb
Aug 17, 2004

gariig posted:

The biggest problem for Scaramouche is it the data isn't 100% static.

quote:

Thanks for the replies guys; I think I either gave too much information or too little! If I was to break down my question into the abstract it'd be: "If I need to refer to a static series of values, is it better to have a database hit once and store the table in session, or should I make a database call every time? (keeping in mind that the table data doesn't change)"

So what is 100% static then? Even if it was 98% static I would not call app pool recycles a no go here if you are deploying as frequently as one should be doing in the modern era.

wwb
Aug 17, 2004

If you do anything to the one that is running it will bounce IIS because the DLLs will change which tells IIS to bounce the app pool.

The best bet if you want to work locally in it would be to check out a 2nd copy in git and develop there while it runs, being very careful of VS.

The better bet for the future is to deploy a copy locally and run long-running tasks there if you don't need interactive debugging for some reason.

wwb
Aug 17, 2004

I'd love to see their stats comparing it to wordpress running on linux under apache or nginx -- I'm not sure their speed claims quite ring true.

wwb
Aug 17, 2004

epalm posted:

When ASP.NET WebAPI processes a request for Content-Type: text/plain, I'd like to return text using my own custom format. Do I need a MediaTypeFormatter like this? I don't see where I'm supposed to customize what my ApiController action returns when it receives a request with Context-Type: text/plain.

This SO question shows how to return a text/plain context-type, but I still want the ApiController action to return a json representation when Context-Type: application/json, and an xml representation when Context-Type: application/xml, etc.

You should use the media type formatter then wire that up in setup. General idea is your service returns an object and the formatter formats things for the wire so your controllers stay format agnostic.

wwb
Aug 17, 2004

idontcare posted:

Regardless if it's a terrible idea or not, I need to do it. Is it possible?

It is a terrible idea. But users authenticated via basic auth do appear in a http header and you should be able to do url rewrites based on that.

But this is loving retarded and you are probably solving a problem in an rear end-backwards way.

wwb
Aug 17, 2004

Ok, still a bit of a retarded architecture but you should be able to do url rewrites based on the HTTP_REMOTE_USER server variable (that you should not be trusting).

Perhaps a better way would be to send everyone to the new URL and then have that redirect folks to the old or new system based on some data lookups -- maintaining that url rewrite file will be a bitch.

Adbot
ADBOT LOVES YOU

wwb
Aug 17, 2004

epalm posted:

Well, I suppose I'd want authors to deal with a (web-application-backed) wiki, and our clients to deal with a User Guide in a browser, but that doesn't mean the CMS has to be running on the client's machine. I think what I'm really after is CMS/Wiki software that can gracefully export its entire contents (html, css, js, images) to a folder. That way, there's no CMS to hack on the client's machine.

Maybe something likey jekyll would work here.

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