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
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
Since we're talking CI I'll say I've had a pretty good experience using the free offering version of AppVeyor and since I use GitHub as my auth account the integration is pretty easy and great.

Adbot
ADBOT LOVES YOU

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

wwb posted:

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.

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?

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

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

This Post Sucks posted:

Hey everyone, I hope this is the right place for this. I've got an issue that I'm banging my head against. We've got a big project that's supposed to deploy this Tuesday and over the last two weeks, I've been getting the following message on our QA box. The biggest thing is that it seems like random sections will break. I can do a redeploy and the error may fix in a previously broken section, yet break in another one. Furthermore, I did a deploy on Thursday; Friday everything worked, then came in this morning and a section that was working on Friday, broke.


After enabling Fusion logging, I get the following Assembly Load Trace:


I can't find any explicit calls in the project that is referencing the System.Web.Razor. I've tried several different solutions that I've came across, but none have seemed to work.

The variable and seemingly random nature of the error is what is really bothering me. Anyone have any ideas?

Thanks!

Edited for more info: Using MVC4, IIS7.5

Are you referencing System.Web.Mvc from any projects that are NOT your actual MVC site? If so, that could be your culprit. Otherwise, given the Fusion log it could be a matter of needing to setup Assembly Bindings in the Web.configs for Mvc and/or Razor. My money is on a project other than an Mvc site containing a reference to System.Web.Mvc though.*

* Because I very stupidly advised a coworker to do this as a shortcut and ended up fighting a nearly identical error for a day before realizing the blunder.

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
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?

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

Bognar posted:

Use int? and check for nulls.

Optionally, if you just want to send them to a custom error page without any special message, use the <customErrors> tag with a redirect in the web.config.

Perfect. Thanks Bognar!

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

epalm posted:

My ASP.NET/razor app lets users save and display messages. When a user saves a message, it contains newlines (the input is a multi-line textarea). When I want to display the message, I want to replace "\n" with "<br/>" so the message shows newlines (breaks) in html. But I don't want the whole message to be raw html, because I don't want users to save messages with iframes/divs/spans/etc.

How do I partially html-ify a string?

Is storing it as Markdown an option?

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

Bognar posted:

What do you guys think? Would anyone else use this?

Agreeing with everyone else. Hot. What's nice about it is it solves one of those "tiny cuts" that we all just deal with. It's the kind of quality-of-life improvement it would be nice to see more of in the core framework.

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

wwb posted:

I'm not trying to rain on your parade -- this is awesome stuff -- but IIRC the MvcContrib and their FluentHtml bits had this stuff integrated back in the MVC1 days. Now, I'm not sure if that library kept up with MVC because most of what it did got subsumed into the framework. Except for this sort of strongly typed stuff.

FWIW one of the issues with this was it was very expensive at scale but this probably matters less in the modern world of javascript rendered pages.

If I remember right, MvcContrib supported something like this through use of T4MVC which was great in concept but incredibly clunky when you tried to use it in your workflow.

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

Brady posted:

Say I wanted to get a string of all characters at the end of a path starting with "\" and going until the end. I'm looking at the string functions and can't find any easy way of doing this. Could anyone offer a hint?

Edit- I guess I would use Split() and return the last element of the array?

Nope- "One dimensional array of 'String' cannot be converted to 'String'.

You don't really say what this is for, but since other's were going with directory/file examples, maybe this is what you're looking for?

code:
Directory.GetFiles(@"c:\test\").Select(Path.GetFileName)
If that's not right, can you give us some example input data and your expected result?

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
I've come across a weird issue with using XDocument to read, update and save a simple XML file. The source file contains a tag with an attribute that has a value like "Randy's Hamburgers" but when loaded/saved using XDocument.Load/Save it's being rewritten as "Randy's Hamburgers" which is causing another system downstream to poo poo itself. What can I do to preserve the files exisiting encoding?

Edit: I think I may have found my answer.

So this would involve me doing some rewrites, which I'm not against but would like to avoid if possible. Thoughts?

Dr. Poz fucked around with this message at 20:17 on May 1, 2015

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

Inverness posted:

You can specify the encoding you want in the TextWriter.

Example of forcing UTF32:
C# code:
using (FileStream fileStream = File.OpenWrite("myfile.xml"))
using (StreamWriter writer = new StreamWriter(fileStream, Encoding.UTF32))
    xdoc.Save(writer);

Interesting, but this doesn't seem to be getting me to the result I'm after as it still leaves the apostrophe in a tags value. For clarity, here is the XML as it exists when I read it in using XDocument.Load:

code:
<?xml version="1.0" encoding="utf-8"?>
<foo stuff="Randy&apos;s stupid burgers">
</foo>
And here is what it looks like when saved out with the XDocument objects Save:

code:
<?xml version="1.0" encoding="utf-8"?>
<foo stuff="Randy's stupid burgers">
</foo>
After running the example code you provided, the document is encoded differently but the apostrophe remains in the "stuff" attribute.

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
Aw shoot, you're right. Derp! I went over the problem with a co-worker a bit earlier and they just got back to me with this solution which seems perfect for the situation.

code:
void Main()
{
	XDocument.Parse(@"<node value=""Randy&apos;s Fine Dinner's"">Randys Fine Diner &gt; other diner &quot; &amp;&amp; &lt; better diner</node>")
		.Save(new SuperXmlTextWriter(Console.Out));
}

class SuperXmlTextWriter : XmlTextWriter
{
	public SuperXmlTextWriter(TextWriter tw) : base (tw) {}
	public override void WriteString(string value)
	{
		base.WriteRaw(SecurityElement.Escape(value));
	}
}

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
It's Friday. Let's have a fight: I've seen some support here and other places in favor of using Query objects to encapsulate data access (EF, NHibernate, Raven, etc) and I tried pulling up a few examples and working out a rough example for a particular itch at work I've wanted scratched. I showed it to a coworker and his concern was that he was seeing the dreaded Repository pattern being called by another name. I can see the argument for it, I suppose. The thing I'm working on really isn't of any consequence, so this may not be the best project to use in the search of a specific answer since the nature of the project can dictate the approach to take but I'm interested in the experiences by those here. For this project, my only real needs are querying the data

What separates the two in your minds? Is this a difference without a distinction? Does the name you call it by not matter? Are they both Anti-Patterns?

Here are some links I looked over while researching.

Query Objects: a better approach than your BLL/repository

https://lostechies.com/jimmybogard/2012/10/08/favor-query-objects-over-repositories/

Well designed query commands and/or specifications

Dr. Poz fucked around with this message at 15:26 on May 29, 2015

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
Thanks for the input that clears up our conceptual issues. Can someone point me to some better links/examples than the ones I posted?

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

chippy posted:

Anyone know why a form created with Ajax.BeginForm() might be POSTing twice to the controller when submit is clicked? I've been trying to debug this for ages and it's starting to make me really angry.

e: Googling just seems to turn up suggestions that it's due to accidentally including minified and regular version of the unobtrusive ajax scripts, which I was initially, but I've fixed this now and I'm still seeing the problem.

Have you cleared your cache? I mean really got in there and cleared your cache?

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
Ran into something weird at work and wanted to see if the forums collective wisdom can help:

Note: This is on Windows 7 x64 and VS2012 Update 5

I'm writing some unit tests for a WebApi controller (which is in an Mvc Project), and I discovered that the base class is making a call directly to HttpContext.Current. Ok, not problem, we are using Autofac and I have some experience with Ninject binding HttpContextBase to return HttpContext.Current so I take a peek to see if there is a "preferred" way to do this. Turns out there is! Autofac.Mvc5. I open up my package manager and paste the install command and get this output:

code:
PM> Install-Package Autofac.Mvc5
Install-Package : Unable to find package 'Autofac.Mvc5'.
At line:1 char:16
+ Install-Package <<<<  Autofac.Mvc5
    + CategoryInfo          : NotSpecified: (:) [Install-Package], InvalidOperationException
    +
Hmm, weird. At this point I notice I don't get tab-based auto-completion on package names either. So I go and right-click my solution and hit "Manage NuGet Packages for Solution..." and here is where poo poo gets REAL weird:

  • I go to "Online" and search for "Autofac.Mvc5". It appears in the results but says it's installed...
  • I got to "Installed packages" and it does NOT appear in the list of packages.
  • I did a search of the entire solution and there seems to be nothing with "Autofac.Mvc5" in it

I tried going to NuGet settings and clearing the cache but that didn't seem to buy me anything. This is pretty strange. Anyone see anything like this before? We are making the switch to VS2015 next week but I'm not fond of just waiting for that if I can fix this in the mean time. Anyone see something like this before? As I mentioned before the tests are for a WebApi controller that is using a base class that seems to be used for all controllers. Autofac.WebApi2 is installed to the project and I can use it but it doesn't seem to have the Autofac module (AutofacWebTypesModule) that I need to register.

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

Finster Dexter posted:

I've never seen that before.

What does your packages.config look like? Is Autofac.Mvc5 in there? (guess not if a solution wide search doesn't find it)

Is it in the packages directory for the solution?

Is your Nuget exe and tooling up to date for VS2012?

It sounds like something is cached or corrupted somewhere, though.

The packages.config for the project I want to add it to does not contain a reference to it.

When I checked the Packages folder for the solution, however it DID contain Autofac.Mvc5.3.3.4 and when I saw this I checked the repositories.config and went through each of the referenced packages.config but none of them contained a reference to Autofac.Mvc so I deleted the folder there and was able to install the package to the project.

Not sure how it ended up there because I double checked and it's not coming from source control. Thanks for pointing out to check the packages folder!

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
We upgraded to VS2015 today! Happy Day! Question: Looking over the Git integration features, it seems like Visual Studio automatically stages all changes. Is this the case? Is there any way to disable this behavior?

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

GrumpyDoctor posted:

Am I correct in assuming that this is a question about how to make changes "excluded" by default, and not one prompted by not noticing that manual exclusion is possible?

That is correct. I would rather not have to manually exclude things. I would prefer to manually stage files like when using git from the command line.

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
So if I'm understanding correctly, the files are not actually staged (i.e. I hit the command line, type "git status" and my modifications aren't staged) but them being "Included" means that if I commit from withing VS that it will stage/commit all "Included" files in a one step process. Is that right?

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

EssOEss posted:

If you are just looking for something to go from a JSON object form to some other object model, I have heard AutoMapper to be a popular mechanism for that sort of thing. Though for my own projects, I do the data mapping manually since it has proven more robust in face of changes.

Please, please, please do not use AutoMapper to go from form post -> domain model. It was not meant to be used this way and down this path lies only pain.

The author of the AutoMapper project routinely answers questions about how to best go about this by discouraging folks from even attempting it.

Dr. Poz fucked around with this message at 16:04 on Mar 23, 2016

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
Like...a menu based game?? Or something at the complexity level of BabySmash? Because otherwise, uh...there are a lot better ways to go about it.

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

ModeSix posted:

I'm using ASP.NET Core and EntityFramework Core.

I'm trying to add an item to a list from a database query doing the following:

code:
IEnumerable<Enrollment> enrollments = _context.Enrollments.Where(se => se.StudentEnrolled == id).ToList();

            List<GroupListViewModel> groups = new List<GroupListViewModel>();

            foreach (var group in enrollments)
            {
                
                var groupadd = _context.Groups.Where(g => g.GroupID == group.GroupId)
                .Select(gl => new GroupListViewModel
                {
                    GroupID = gl.GroupID,
                    BookID = gl.BookID,
                    Level = gl.Level,
                    NumberOfEnrollments = _context.Enrollments.Where(gi => gi.GroupId == gl.GroupID).Count(),
                    TeacherName = _context.ApplicationUser.Where(ti => ti.Id == gl.ApplicationUserID)
						.Select(tn => tn.LastName + ", " + tn.FirstName).FirstOrDefault()
                });

                groups.Add(groupadd);
	  }
On the groups.Add(groupadd); segment, it is giving me an error that says:


So my question is, what did I do wrong? Why won't it let me add an item to the List<GroupListViewModel> ?

Without more context, it looks like your .Select is going to return an IQueryable result which could potentially contain multiple objects. Then you are trying to add it as a single object to your list. You can either use SingleOrDefault or FirstOrDefault to make it to a single object. If you WANT the possibility of a collection being returned by your .Select then you can pass the results to .AddRange on your list instead of .Add.

Adbot
ADBOT LOVES YOU

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
Created the basic dockerized ASPNET Core template project and figured out how to manually specify the ports I wanted the app on. Then I added Container Orchestrator Support and figured out how to manually specify the ports I wanted to use. Figuring out how to override these values via documentation wasn't difficult but I was a little surprised the initial port definition seems to be configured only via magic. I initially expected to be able to search my way to changing the value, at first by searching for the port number itself, failing that the launchSettings.json or even some value defined in the .csproj settings.

While the launchSettings.json (and later docker-compose.override.yml) were where I would eventually override the values successfully did I miss some bit of initial configuration along the way or is this just a dash of "magic" for new projects?

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