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
Polio Vax Scene
Apr 5, 2009



Why the gently caress did .NET MVC work perfectly fine yesterday then absolutely poo poo the bed when I rebuilt and published this morning? I fixed it by readding the references and setting copy local to true but it is not the first time this has happened.

Adbot
ADBOT LOVES YOU

Polio Vax Scene
Apr 5, 2009



EssOEss posted:

There is probably something wrong with your project setup. I have never seen a case where "Setting copy local to true" is a meaningful step for a well-formed project, only cases where it can be sort of used to hide some deeper underlying issue.

I believe readding references fixed it, copy local was a panic move.

Polio Vax Scene
Apr 5, 2009



Trying to transition to visual studio 2015 and it's breaking on exceptions even if it's in a try/catch and even if I have all the exception types unchecked in the exception handler. What gives?

Polio Vax Scene
Apr 5, 2009



Already on, unfortunately.

Polio Vax Scene
Apr 5, 2009



Is there a way in visual studio to check a project for all uses of any enums? I'm having serialization problems with them, but its not just one specific enum, and I have a few hundred of them to sort out (tool generated).

Polio Vax Scene
Apr 5, 2009



What would be the best way to have a .net 3.5 console app communicate with a .net 4.0 console app?

Polio Vax Scene
Apr 5, 2009



RICHUNCLEPENNYBAGS posted:

Do they run on the same machine? PowerShell may be an option.

I ended up just publishing a web site with a .svc :downs:

Polio Vax Scene
Apr 5, 2009



What would be the best way to create a web URL that has a base64 encoded string in it? I had a problem with forward slashes earlier, are there other characters I might need to worry about?

Polio Vax Scene
Apr 5, 2009



epalm posted:

I'm assuming you mean this?



It's version 5.2.3.0

This is the properties window of the file that gets copied to the bin direction. The version doesn't seem to match, but I'm not sure what "version" it's referring to.



Are there any other projects in your solution that use it? What happens if you remove and readd the reference then rebuild?

Polio Vax Scene
Apr 5, 2009



We're in the planning phase of a project and I want to get a general opinion of our current plan.
1. User navigates to "upload" page
2. User uploads file
3. File is saved on the server (temporary files?)
4. Upon successful upload, user is redirected to a "review" page
5. File is run through some components to extract data, data is populated into the "review" page
6. User reviews/modified the extracted data on the review page, then submits
7. A record is created in a database from the data, and the file is saved to a new non-temporary location which is linked to from the record.
My biggest concern is how to deal with the file's persistence, making sure that it is properly cleaned up if the user backs out somewhere between steps 4 and 7 but also stays around for the entire process. Also, what would be the best way to make the review page recognize the file that was uploaded? I was thinking when the file was saved in step 3 to give it a GUID for a name, and pass that as a URL parameter to the review page when redirected but the filename will still be important for step 7.

Polio Vax Scene
Apr 5, 2009



Is there a way to make an XML serializer print like this:
pre:
<Contact>
  <FirstName>Bob</FirstName>
  <MiddleName></MiddleName>
  <LastName>Smith</LastName>
</Contact>
Instead of like this?:
pre:
<Contact>
  <FirstName>Bob</FirstName>
  <MiddleName />
  <LastName>Smith</LastName>
</Contact>
That doesn't involve painfully manually writing out the XML?

v That is (un)fortunately beyond the scope of my responsibility.

Polio Vax Scene fucked around with this message at 17:43 on Oct 7, 2016

Polio Vax Scene
Apr 5, 2009



Is there any functional difference between these two?:

var x = DoThingAsync().Result;

var y = DoThingAsync();
y.Wait();
var x = y.Result;

I understand that both go against the whole point of the async methodology, this is just for a POC console app.

Polio Vax Scene
Apr 5, 2009



Something like this?:

pre:
        static T[] Foo<T>(params T[] c)
        {
            var ret = new List<T>();
            foreach (var obj in c) { ret.Add(obj); }
            return ret.ToArray();
        }
Seems kind of redundant to me but maybe I'm misunderstanding the goal

Polio Vax Scene
Apr 5, 2009



This was my favorite site starting out.
https://www.dotnetperls.com/

Polio Vax Scene
Apr 5, 2009



I'm lost and need some guidance. We're building an integration with a third party that uses JWTs to authenticate users. The tokens are signed using an x509 cert.
When I use the System.IdentityModel.Tokens.Jwt package to generate a token, it adds an x5t header to the token. We need this to be an x5c header instead, as the third party will not support x5t signed tokens. I've been struggling to find a way to change how the token is signed with no luck.

code:
var certBytes = System.IO.File.ReadAllBytes("certificate.pfx");
var cert = new System.Security.Cryptography.X509Certificates.X509Certificate2(certBytes, "******");

var claims = new List<Claim>
{
    new Claim("sub", "test"),
};

var x509SigningCredentials = new X509SigningCredentials(cert);

JwtSecurityToken securityToken = new JwtSecurityToken(
    claims: claims,
    notBefore: DateTime.UtcNow,
    expires: DateTime.UtcNow.AddMinutes(60),
    signingCredentials: x509SigningCredentials);

Console.WriteLine(securityToken.Header.X5t); // No option for x5c in this class

Polio Vax Scene
Apr 5, 2009



Yep, the third party engineer was very helpful and was able to provide a sample. So below is my x5c header token code, for posterity.

code:
var certBytes = System.IO.File.ReadAllBytes("certificate.pfx");
var cert = new System.Security.Cryptography.X509Certificates.X509Certificate2(certBytes, "******");

var claims = new List<Claim>
{
    new Claim("sub", "test"),
};

//Replaced with below
//var x509SigningCredentials = new X509SigningCredentials(cert);

                    RsaSecurityKey rsaSecurityKey = new RsaSecurityKey(cert.GetRSAPrivateKey());
                    var x509SigningCredentials = new SigningCredentials(rsaSecurityKey, SecurityAlgorithms.RsaSha512); ;

JwtSecurityToken securityToken = new JwtSecurityToken(
    claims: claims,
    notBefore: DateTime.UtcNow,
    expires: DateTime.UtcNow.AddMinutes(60),
    signingCredentials: x509SigningCredentials);

//This is the new x5c header stuff
                    X509Chain chain = new X509Chain();
                    chain.Build(cert);
                    List<string> x5cList = new List<string>();
                    foreach (var element in chain.ChainElements)
                    {
                        x5cList.Add(Convert.ToBase64String(element.Certificate.RawData));
                    }
                    securityToken.Header.Add("x5c", x5cList.ToArray());

Polio Vax Scene
Apr 5, 2009



I'm looking at options for extending a .net core program I've written so that users can create libraries that will be loaded up and imported.
Looking at options I see MEF is available in .net core now but I'm not finding a lot of information regarding security.
Where can I get info on restricting what actions are available in the loaded libraries' operations?

Polio Vax Scene
Apr 5, 2009



That is precisely what I meant.
Hmm...so would the next best idea be some sort of lua-like scripting module? Open to suggestions

Polio Vax Scene
Apr 5, 2009



It's the latter, with the intent being distribution of plug-ins amongst the community that uses the program. Like what's a way to stop someone from making a plug-in that deletes (or attempts to) all the files in their C: drive?
Maybe I just need to have some sort of open source review and master build process instead of letting community members build their own plug-ins?

Polio Vax Scene
Apr 5, 2009



I've got a weird issue where I'm trying to separate strings into segments and if a unicode character happens to be right at the segmentation point it'll get "chopped in half"



What would be a good way to avoid this?

Polio Vax Scene
Apr 5, 2009



Mata posted:

I think you can use char.IsLowSurrogate or IsHighSurrogate to detect this case.

I actually did a pull request a while back to fix an issue where deleting chars from a textbox one at a time using backspace would break if the textbox contained emojis and such. https://github.com/rds1983/Myra/pull/316/commits/07a29096bb852f9090c99740a7d3514202a78a70

Thanks, this is exactly what I needed.

Polio Vax Scene
Apr 5, 2009



There's a developer on our team that continues to use .NET Framework for all their work. I think they're intimidated by .NET Core or something. Any good resources you recommend that can be used to convince them to swap?


vvv Even though we are on the same team, we primarily work on separate projects. The requirement to have all projects on the same framework has not been mandated yet, but I suspect that will be happening soon, and want to have as little friction as possible when it does become reality.

Polio Vax Scene fucked around with this message at 17:58 on Dec 20, 2021

Polio Vax Scene
Apr 5, 2009



Writing the code is the least important part of writing code

Polio Vax Scene
Apr 5, 2009



NihilCredo posted:

System.Globalization.CultureInfo.IdgafAboutCulture

uncultured swine

Polio Vax Scene
Apr 5, 2009



Your team, a team of intellectuals: Have we considered doing a benchmark test of string concatenation methods to identify the most efficient way to generate our log files? We could increase performance by up to 4%!

My team:
code:
        private int GetEndTagPosition(string searchstring, string Tag)
        {
            int EndTagPosition = 0;
            int pos1 = 99999, pos2 = 99999, pos3 = 99999, pos4 = 99999, pos5 = 99999, pos6 = 99999, pos7 = 99999, pos8 = 99999;
            searchstring = searchstring + ' ';
            pos1 = searchstring.IndexOf(' ', searchstring.ToUpper().IndexOf(Tag.ToUpper()) + Tag.Length + 1);
            pos2 = EndTagPosition = searchstring.IndexOf("\t", searchstring.ToUpper().IndexOf(Tag.ToUpper()) + Tag.Length + 1);
            pos4 = searchstring.IndexOf("<br>", searchstring.ToUpper().IndexOf(Tag.ToUpper()) + Tag.Length + 1);
            pos3 = searchstring.IndexOf("\n", searchstring.ToUpper().IndexOf(Tag.ToUpper()) + Tag.Length + 1);
            pos5 = searchstring.IndexOf(",", searchstring.ToUpper().IndexOf(Tag.ToUpper()) + Tag.Length + 1);
            //pos6 = searchstring.IndexOf(".", searchstring.ToUpper().IndexOf(Tag.ToUpper()) + Tag.Length + 1); //removed since it causes issues with email addresses
            pos7 = searchstring.IndexOf(":", searchstring.ToUpper().IndexOf(Tag.ToUpper()) + Tag.Length + 1);
            pos8 = searchstring.IndexOf(";", searchstring.ToUpper().IndexOf(Tag.ToUpper()) + Tag.Length + 1);
            //EndTagPosition = Math.Min((pos1 == -1) ? 99999 : pos1, Math.Min((pos2 == -1) ? 99999 : pos2, Math.Min((pos3 == -1) ? 99999 : pos3, (pos4 == -1) ? 99999 : pos4))) - 1;
            EndTagPosition = Math.Min(
                (pos1 == -1) ? 99999 : pos1,
                    Math.Min((pos2 == -1) ? 99999 : pos2,
                        Math.Min((pos3 == -1) ? 99999 : pos3,
                            Math.Min((pos4 == -1) ? 99999 : pos4,
                                Math.Min((pos5 == -1) ? 99999 : pos5,
                                    Math.Min((pos6 == -1) ? 99999 : pos6,
                                        Math.Min((pos7 == -1) ? 99999 : pos7,
                                            (pos8 == -1) ? 99999 : pos8))))))) - 1;
            if (EndTagPosition == -99998)
            {
                EndTagPosition = 0;
            }

            return EndTagPosition;
        }

Polio Vax Scene
Apr 5, 2009



My work falls into one of these categories
- little scripts or programs to shuffle data around
- backend data transformations, validations, restrictions from user submitted data
- building various integration APIs between our stuff and 3rd parties

There's SOME UI stuff occasionally but we let Microsoft's products do most of the heavy lifting on the front end

Adbot
ADBOT LOVES YOU

Polio Vax Scene
Apr 5, 2009



we have a company license for devexpress so we just feed it into that steamroller

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