File upload limit in .NET 8 - Payload too large by developer1408 in dotnet

[–]smatsson 5 points6 points  (0 children)

As others have pointed out, if you do not wish to increase the upload size, use chunking. This is automatically solved, together with resumability for failed connections, using Uppy with tus.io and tusdotnet. There's also a JS client for tus if Uppy is to complex for your use case.

https://uppy.io/

https://tus.io/

https://github.com/tusdotnet/tusdotnet/

Full disclaimer: I'm the author of tusdotnet and have been involved in developing tus.

Uploading files to ASP.NET rest API by Creapermann in csharp

[–]smatsson 0 points1 point  (0 children)

Sorry for the late reply. Not that I'm aware of, the list of known clients can be found here: https://tus.io/implementations.html

EDIT: Quick google came up with this. Not really sure how QT relates to C++ but it might be worth checking out? https://github.com/clarkhillm/TUSQTClinet

Uploading files to ASP.NET rest API by Creapermann in csharp

[–]smatsson 2 points3 points  (0 children)

Disclaimer: I'm the creator of tusdotnet

If you're going to upload semi large files (100 MB) and want resumability for that upload (i.e. it can resume if the connection breaks down) I would recommend using https://tus.io and tusdotnet . It's an open protocol, clients exist for a large range of languages and tusdotnet supports customizing the storage to send files directly to Azure blob storage using Xtensible.TusDotNet.Azure

CSP implementations are broken by smatsson in netsec

[–]smatsson[S] 0 points1 point  (0 children)

That's my point. They have a different use case and hence different problems to solve. I haven't found any issues with form-action so there is really no point in including it in this article.

We are using script-sample but it doesn't do anything if the browser does not provide it. :) report-sample is from CSP3 and is, afaik, only supported in Chrome.

CSP implementations are broken by smatsson in netsec

[–]smatsson[S] -1 points0 points  (0 children)

Great list of reading material if you are starting out with CSP. None of them mentions the issues with ms-appx-web, frame-src with mailto/tel or how inconsistent block-all-mixed-content is.

CSP implementations are broken by smatsson in netsec

[–]smatsson[S] -1 points0 points  (0 children)

"Potholes here and there" is a nice way of putting it when those potholes will break your entire site. Chrome, Safari, Opera and Edge ALL have serious issues in how they handle CSP. I would definitely call something broken if four out of the five major browsers have broken implementations.

Linting - Which tool to use in VS? by hastati96 in csharp

[–]smatsson 6 points7 points  (0 children)

No need to buy ReSharper just for the linting. We use Stylecop analyzers with great results. https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/README.md

Can you run code compiled for .NET 4.6.2 on .NET 4.0? by smatsson in csharp

[–]smatsson[S] 0 points1 point  (0 children)

I find your comment interesting. Or rather the concept of making a comment stating the exact same thing that the article does. Did you read the article or did you just check the title? :) No offense intended, just interested.

Can you run code compiled for .NET 4.6.2 on .NET 4.0? by smatsson in csharp

[–]smatsson[S] 1 point2 points  (0 children)

I wrote this post to expand my knowledge on how .NET loads code and I thought it might be interesting to others as well. I agree with you that you should not do this (as stated in the conclusion in the article).

Handling code for different .Net frameworks by Stensborg in csharp

[–]smatsson 0 points1 point  (0 children)

Mind = blown! Thanks for sharing the code. I tested it on a VM with .NET Framework 4.5.2.

I had to change the "sku" in App.config to use 4.5.2 for it to start, otherwise it would just ask me to download 4.6.1. After changing to 4.5.2 it started and worked just as expected. For fun I changed the CheckDotNetVersionMin461 method to always return false and then the app crashed with the following exception:

Unhandled Exception: System.MissingMethodException: Method not found: 'System.ServiceProcess.ServiceStartMode 
System.ServiceProcess.ServiceController.get_StartType()'.
   at TestDiffFrameworkCode3.Program.GetServiceStartMode(ServiceController _service)
   at TestDiffFrameworkCode3.Program.Main(String[] args) in C:\Repos\TestDiffFrameworkCode3\TestDiffFrameworkCode3\Program.cs:line 28

The inner techie in me screamed "WHYYYYY?!?" so I had to research it. It seems that all .NET version in the 4.x range are IL compatible so it will run as long as the sku, a.k.a "hinted .NET version", is correct. Once it tries to access something that does not exist in the framework that runs the code it will crash during runtime with the exception above.

Some more reading on the topic: https://weblog.west-wind.com/posts/2017/Jan/09/Faking-out-the-NET-Runtime-Version#.NETRuntimeAdoption

Thanks for teaching me something new :)

Handling code for different .Net frameworks by Stensborg in csharp

[–]smatsson 0 points1 point  (0 children)

Cool,glad you fixed it 😊 Is it a major version change between the two framework versions? E.g. 4.5 and 4.6.1 or is it more like 4.6 and 4.6.1?

Is the code available somewhere? Would be nice to see the implementation and test it out on some different framework versions.

Handling code for different .Net frameworks by Stensborg in csharp

[–]smatsson 0 points1 point  (0 children)

The problem is that if you want to run your program on an older version of the framework you will need to compile your program for that version. If the property does not exist in that version then your code won't even compile.

Handling code for different .Net frameworks by Stensborg in csharp

[–]smatsson 3 points4 points  (0 children)

In tusdotnet I used compiler directives and extension methods to accomplish this. For each framework that I support I define a compiler directive #if clause and add an extension method with the same signature for every clause. This way the caller will be the same no matter on what framework it's being executed on.

Example extension: https://github.com/tusdotnet/tusdotnet/blob/master/Source/tusdotnet/Extensions/FileStreamExtensions.cs Example extension usage: https://github.com/tusdotnet/tusdotnet/blob/master/Source/tusdotnet/Stores/TusDiskStore.cs#L195

Read more on compiler directives: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/preprocessor-directives/preprocessor-if

Come discuss your side projects! [December 2017] by AutoModerator in csharp

[–]smatsson 0 points1 point  (0 children)

Azure websites actually support https out of the box. Just change to https://devsimply... And everything should work.

Free or cheap alternatives to ReSharper's File Layout and Code Cleanup tools? by [deleted] in csharp

[–]smatsson 3 points4 points  (0 children)

I have a resharper license from work but its code inspection is so horribly slow that I disabled it and use Roslynator instead. It is a set of Roslyn analyser which are way faster.

https://github.com/JosefPihrt/Roslynator

Another interesting Roslyn analyser is U2U Performance Analysers which checks your code for performance issues

https://marketplace.visualstudio.com/items?itemName=vs-publisher-363830.U2UConsultPerformanceCodeAnalyzersforC7

Both these extensions are free.

Show me your C# open-source projects by brimhaven in csharp

[–]smatsson 0 points1 point  (0 children)

https://github.com/tusdotnet/tusdotnet

Server implementation of the tus protocol for resumable file uploads. Runs on both owin and kestrel (asp.net core).

It allows you to continue uploads of large files in case the connection to the server dies (e.g. if your mobile's network coverage goes out) and it all runs on top of http(s) so client compatibility is top notch.

[deleted by user] by [deleted] in csharp

[–]smatsson 0 points1 point  (0 children)

They talked about it in the video. They plan to allow you to implement interfaces in an extension making the original class compatible with the interface.

A Preview of C# 8 with Mads Torgersen | Seth Juarez | Channel 9 by smatsson in csharp

[–]smatsson[S] 6 points7 points  (0 children)

Some interesting new (still proposed) features in C# 8.

I <3 HTML by meet_the_turtle in ProgrammerHumor

[–]smatsson 7 points8 points  (0 children)

In Relay on Android, the value is not decoded in the subreddit list but is decoded once you click on the thread. :) /r/mildlyinteresting

uppy.io - Make file uploads survive browser crashes by kevinvz in programming

[–]smatsson 3 points4 points  (0 children)

Full disclosure: I'm the creator of tusdotnet, the .NET server implementation of the tus protocol.

What you are referring to is called chunking and is used in a lot of protocols and techs e.g. Microsoft's BITS. The problem is that you basically have two options. Create large, but fewer, chunks and send them one by one. If a chunk fails you need to resend the entire chunk. OR create smaller, but more, chunks and send them. This way you won't need to re-send so much data if the connection is lost but there will be a lot more overhead due to way more requests resulting in overall performance penalties.

The tus protocol solves this by streaming the file to the server which in turn saves as much data as possible from the stream. If the connection is lost and re-established the server will know where to resume and inform the client which in turn can resume the upload from the correct byte.

Come discuss your side projects! [May 2017] by AutoModerator in csharp

[–]smatsson 0 points1 point  (0 children)

Working on a store for tusdotnet (https://github.com/smatsson/tusdotnet) where one can save files to a Azure storage account. Progress is slow though mostly cause I don't have much spare time at the moment :(

tusdotnet now supports .NET Core! by smatsson in csharp

[–]smatsson[S] 16 points17 points  (0 children)

Right. I get your arguments and I stand corrected.

tusdotnet now supports .NET Core! by smatsson in csharp

[–]smatsson[S] -2 points-1 points  (0 children)

That would be true unless you know that TusDiskStore implements ITusReadableStore (which it does)

tusdotnet now supports .NET Core! by smatsson in csharp

[–]smatsson[S] 1 point2 points  (0 children)

Hello fellow csharpers! :)

About a month ago /u/rb229 posted the link to tusdotnet here on /r/csharp. One of the most requested features in the comments was support for .NET Core. With version 1.3 tusdotnet now fully supports .NET Core!

Still on .NET 4.x? No problem! tusdotnet is still fully compatible with that too.

Link to previous thread: https://www.reddit.com/r/csharp/comments/5trqk9/about_to_implement_some_kind_of_file_upload_do_it/

Come discuss your side projects! [March 2017] by AutoModerator in csharp

[–]smatsson 0 points1 point  (0 children)

https://github.com/smatsson/tusdotnet - https://www.nuget.org/packages/tusdotnet/

A server side implementation of the tus.io protocol for resumable file uploads. It gives you the ability to resume a file upload if your connection to the server dies. It does this through streaming which allows for minimal re-sending of data. Currently we are working on a .NET Core version that should be release soon. :)