|
I recently uploaded a ASP.net site to a host that uses plesk. For some reason file upload isn't working for the site on the host. I get an unknown error after I select a file to upload. But it works fine when I load the site on my local IIS server. I'm not sure what may cause this error because the message doesn't specify the cause, so I'm not even sure where to begin looking.
|
# ? May 17, 2020 08:04 |
|
|
# ? Jun 3, 2024 05:53 |
|
Check file permissions in the upload folder on the server?
|
# ? May 17, 2020 08:19 |
|
beuges posted:Check file permissions in the upload folder on the server? oh my god that worked, can't believe it was that simple. Thanks!
|
# ? May 17, 2020 09:03 |
|
I'm working on an API for our web software and am having a little trouble building out the module that allows the user to upload a file. In the actual Web project, it's done like so: code:
To test uploading via the API, I uploaded a document from the actual Web software, and then copied the Data field from SQL Server to my clipboard to paste into Swagger while testing the API, but when I do this I get the error: "The JSON value could not be converted to System.Byte[]. Path: $.data | LineNumber: 0 | BytePositionInLine: 6888" Should I just make this field a string or something? I don't really understand why the Web project throws a byte[] into the field, but I can't throw the field into a byte[] from the API
|
# ? May 19, 2020 13:59 |
|
Sab669 posted:I'm working on an API for our web software and am having a little trouble building out the module that allows the user to upload a file. Your controller's code is probably most pertinent for figuring out what's going on here. Generally byte[] needs to be as serialized as something to go over the wire. It could a base64 string, it could be BSON...
|
# ? May 19, 2020 14:25 |
|
Whatever serializer is running there might be expecting a JSON array of numbers.
|
# ? May 19, 2020 14:25 |
|
Bruegels Fuckbooks posted:Your controller's code is probably most pertinent for figuring out what's going on here. Generally byte[] needs to be as serialized as something to go over the wire. It could a base64 string, it could be BSON... The full Web Controller (works) is as so: code:
code:
code:
|
# ? May 19, 2020 14:35 |
|
Sab669 posted:... https://web.archive.org/web/2012051...e#multipartmime E: actually you can do this the same way via HttpContext.Current.Request.Files in WebAPI. That way the request to Web Controller and Web API would look the same, just to a different URL. If you do need to go the JSON route then you'll need to encode the byte content of the document as a base64 string or similar. Trying to send actual "byte"/number arrays would be incredibly inefficient. SirViver fucked around with this message at 15:17 on May 19, 2020 |
# ? May 19, 2020 15:13 |
|
SirViver posted:Is there a specific reason you try to send the file as a JSON payload? Usually files over HTTP are sent as multipart/form-data request, which is what I believe Request.Files resolves under the hood in the Web Controller. To be honest I don't really know what I'm doing I don't have much experience with writing APIs or handling files. I didn't write the web controller either, and the senior architect was fired just as all this covid poo poo went down so I'm kind of on my own here I figured I'd just try to keep this as close to how the rest of the API wass being written for all our "business entities" within the software where we just pass in some JSON values and convert it to an object and write it to the DB.
|
# ? May 19, 2020 15:26 |
|
An ajax get is giving me an 404 error on the server but the function works fine locally. Locally the variable 'data' returns true and everything works fine, but on the server 'data' returns a generated html code with 404 errors. I googled and found a lot of people with similar issues but the solutions were really specific. This is the function code:
code:
|
# ? May 19, 2020 19:05 |
|
SirViver posted:Is there a specific reason you try to send the file as a JSON payload? Usually files over HTTP are sent as multipart/form-data request, which is what I believe Request.Files resolves under the hood in the Web Controller. This. His code is fine, or close enough. The problem is that he's testing it using Swagger (I assume he means Swagger UI), which doesn't have a file upload button, just a text field that becomes the request body. Test the API with something like Postman and you'll be able to attach actual files to the request.
|
# ? May 19, 2020 19:44 |
|
NihilCredo posted:This. His code is fine, or close enough. The problem is that he's testing it using Swagger (I assume he means Swagger UI), which doesn't have a file upload button, just a text field that becomes the request body. Oh, this I do have Postman but I've never used it. The aforementioned sr architect we lost had me download it but never had time to tell me what it was for
|
# ? May 19, 2020 19:56 |
|
NihilCredo posted:This. His code is fine, or close enough. The problem is that he's testing it using Swagger (I assume he means Swagger UI), which doesn't have a file upload button, just a text field that becomes the request body. You can get swagger ui to display a file button with the right annotations, but it requires a bit of futzing about depending on what version of swashbuckle you’re using. Assuming he’s using swashbuckle.
|
# ? May 19, 2020 19:56 |
|
Revalis Enai posted:An ajax get is giving me an 404 error on the server but the function works fine locally. Erm, have you tried looking in the browser's dev console network log to see what the actual full request URL of that ajax call is? Maybe it tries to navigate from the website root (or not from root), resulting in the wrong URL being called? At least that's usually a problem I encounter when running in Visual Studio's built in webserver vs. applications actually running on IIS.
|
# ? May 19, 2020 20:59 |
|
SirViver posted:Erm, have you tried looking in the browser's dev console network log to see what the actual full request URL of that ajax call is? Maybe it tries to navigate from the website root (or not from root), resulting in the wrong URL being called? At least that's usually a problem I encounter when running in Visual Studio's built in webserver vs. applications actually running on IIS. The full request url of the server is code:
code:
|
# ? May 19, 2020 21:45 |
|
Revalis Enai posted:The full request url of the server is mystes fucked around with this message at 21:57 on May 19, 2020 |
# ? May 19, 2020 21:55 |
|
Revalis Enai posted:
302 is a redirect, look at the response header and see what it’s trying to redirect to.
|
# ? May 20, 2020 01:11 |
|
Jen heir rick posted:302 is a redirect, look at the response header and see what it’s trying to redirect to. I looked at the header for Clear.aspx from both sites and only the live server shows a location code:
|
# ? May 20, 2020 05:28 |
|
Revalis Enai posted:I looked at the header for Clear.aspx from both sites and only the live server shows a location It’s trying to redirect to an error page, but Ajax calls won’t follow redirects. You should try making the same call using Postman.
|
# ? May 20, 2020 11:27 |
|
I tried to access clear.aspx from my local server and I get a blank page with the word 'true' in the page, which is what I expected to see. When I tried to access clear.aspx from the live server, it directs me to the custom 404 error page. Right now what I don't know is why it's doing so. I Other aspx files on the live server seem to be loading up with no issue. The header from the live server has some additional items. I also noticed the content length from the local server is longer than the live server.
|
# ? May 20, 2020 18:49 |
|
I was finally able to fix the issue! I found a way to temporary stop the redirect and to have the site show me what error was actually being thrown out. This is what it came up: code:
code:
I'm still new to ASP.net but having to debug someone else's code is forcing me to cram as much into my brain as quickly as possible.
|
# ? May 21, 2020 16:58 |
|
Azure question Does anyone else here work with Azure Functions? I've noticed that they recently redid the whole layout, and in general it's much better. But they seem to have removed the option to see Console output from the invocations, is this gone for real or am I missing a setting somewhere to turn it back on? All I see is "Logs" at the bottom, which only updates with an occasional line of output, not all of them.
|
# ? May 22, 2020 03:25 |
|
We've got some ASP.NET Framework projects that use dependency injection. Some classes take 8-10 different injected classes, and I think it looks cluttered. Is there a better way?
|
# ? May 22, 2020 11:27 |
|
Boz0r posted:We've got some ASP.NET Framework projects that use dependency injection. Some classes take 8-10 different injected classes, and I think it looks cluttered. Is there a better way? If it's like most projects, 6-7 of those classes are basic stuff that virtually everything depends on, like loggers and databases. Wrap those in a "commons" POCO and inject that.
|
# ? May 22, 2020 12:38 |
|
Just accept it and move on. Yes, if your class has 15 dependencies, you need to list 15 dependencies. By hiding that you'll make more trouble for yourself and your readers later on. Be explicit. Some things in life just are.
|
# ? May 22, 2020 20:01 |
|
If any of those dependencies can use null implementations and aren’t relevant in unit tests, you can use property injection to tidy up your constructors. I’ve seen this work well with logging specifically but there might easily be other cases where it works well.
|
# ? May 22, 2020 20:12 |
|
Boz0r posted:We've got some ASP.NET Framework projects that use dependency injection. Some classes take 8-10 different injected classes, and I think it looks cluttered. Is there a better way? Your classes are too big and doing too much.
|
# ? May 22, 2020 20:52 |
|
New Yorp New Yorp posted:Your classes are too big and doing too much. it's this. also, the decorator pattern might help with concerns like logging.
|
# ? May 22, 2020 20:56 |
|
26-parameter constructor crew checking in
|
# ? May 22, 2020 23:27 |
|
New Yorp New Yorp posted:Your classes are too big and doing too much. Yep, it's a really stinky code smell that you need to start breaking apart or clustering those dependencies. Plenty of DI tips on this blog: https://blog.ploeh.dk/2018/08/27/on-constructor-over-injection/
|
# ? May 23, 2020 00:34 |
|
NihilCredo posted:If it's like most projects, 6-7 of those classes are basic stuff that virtually everything depends on, like loggers and databases. Wrap those in a "commons" POCO and inject that. wtf no
|
# ? May 23, 2020 17:36 |
StrixNebulosa posted:I think my favorite thing about Autonauts so far is how stupid these robots are. They do exactly what you tell them to do and nothing more. I just found this in the Steam thread.
|
|
# ? May 23, 2020 17:45 |
|
SimonChris posted:I just found this in the Steam thread. Strix is becoming enlightened.
|
# ? May 23, 2020 18:21 |
|
New Yorp New Yorp posted:Your classes are too big and doing too much. Maybe. Sometimes your class just implements 1 simple concept and needs to call 10 different things once or twice when doing so. If you can post code, Boz0r, we might be able to offer specific advice on how to do better. What is "better" here can be very situational and it's easy to get carried away by doing low-cost-effectiveness changes just for theoretical benefit.
|
# ? May 23, 2020 22:17 |
|
Are there any tools for keeping track of Nuget packages and their dependencies? Our client has developed a sudden interest in packaging our projects, and now I've got missing dependencies from a Nuget package's dependency, or something.
|
# ? May 26, 2020 16:51 |
|
Boz0r posted:Are there any tools for keeping track of Nuget packages and their dependencies? Our client has developed a sudden interest in packaging our projects, and now I've got missing dependencies from a Nuget package's dependency, or something. You can either enable the creation of lock files or start using Paket.
|
# ? May 26, 2020 17:36 |
|
EssOEss posted:Maybe. Sometimes your class just implements 1 simple concept and needs to call 10 different things once or twice when doing so. Someone had the brilliant idea of wrapping our DbContext-equivalent for CRM in a SAL that exposes set queries. Each entity has their own Service Manager, and the DI is injecting 8 different Service Managers because the BLL needs 8 different entities.
|
# ? May 29, 2020 11:01 |
|
Boz0r posted:Someone had the brilliant idea of wrapping our DbContext-equivalent for CRM in a SAL that exposes set queries. Each entity has their own Service Manager, and the DI is injecting 8 different Service Managers because the BLL needs 8 different entities. That totally does not sound convoluted in any way. This seems the be big issue with these "patterns", people think they have to do it "everywhere" otherwise they suck as a coder.
|
# ? May 30, 2020 09:06 |
|
Boz0r posted:Someone had the brilliant idea of wrapping our DbContext-equivalent for CRM in a SAL that exposes set queries. Each entity has their own Service Manager, and the DI is injecting 8 different Service Managers because the BLL needs 8 different entities. oh yeah, we do a similar thing - hence the class with 26+ parameters in its constructor
|
# ? May 30, 2020 09:21 |
|
|
# ? Jun 3, 2024 05:53 |
|
How much do you use nuget packages? We've got an old repo in TFS that's using a proxy nuget package to communicate with our new web services in git. We've got a solution for each different web service, and a couple of shared projects. Someone has started making nuget packages of the shared projects to avoid shared dependencies in projects, and I don't really see the point, and I don't know if it'll screw with some of our tools.
|
# ? May 31, 2020 13:12 |