visual studio Web Service Request 415 error - c#

I am trying to this tutorial to my project:
I set header: SOAPAction as http://somuri.com/IHubService/processAirLFSearch
and my body looks like:
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://someuri.com">
<soapenv:Header/>
<soapenv:Body>
<OTA_AirLowFareSearchRQ>
...
</OTA_AirLowFareSearchRQ>
</soapenv:Body>
</soapenv:Envelope>
finally my url to service is: http://localhost:24030/HubService.svc
But I constantly this error:
HTTP/1.1 415 Cannot process the message because the content type
'application/octet-stream' was not the expected type 'text/xml;
charset=utf-8'.
What am I doing wrong?
By the way here what looks like my project screen shot:

What captured in fiddler:
This is successful request header
POST http://mycomputer:8989/MyService.svc HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: text/xml;charset=UTF-8
SOAPAction: "http://someuri.com/Login"
Content-Length: 389
Host: mycomputer:8989
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
and this is unsuccessful request header
POST http://mycomputer:8989/MyService.svc HTTP/1.1
SOAPAction: http://someuir.com/Login
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)
Accept: */*
Accept-Language: en-US
Accept-Encoding: GZIP
Host: mcomputer:8989
Content-Length: 1604
Expect: 100-continue
Connection: Keep-Alive
So it is missing
Content-Type: text/xml;charset=UTF-8
So in visual studio in web performance test setting Content-type on String body solves problem

Related

Why is HttpClient authentication behaving differently between .Net Framework 4.6.2 and .Net Core 5?

I have the same code as below targeting .Net Framework 4.6.2 and .Net Core 5 but seems to yield different authentication behavior.
The .Net Framework version works fine with WWW-Authenticate: Negotiate but the same code fails with the .Net Core version.
Here's the code snippet that I'm using for both.
var server = "https://www.example.com";
var client = new HttpClient(new HttpClientHandler { UseDefaultCredentials = true }) { BaseAddress = new Uri(server) };
var response = await client.GetAsync("/api/token");
var result = response.Content.ReadAsStringAsync().Result;
Console.WriteLine(result);
And here's the entire failure response.
StatusCode: 401, ReasonPhrase: 'Unauthorized', Version: 1.1, Content: System.Net.Http.HttpConnectionResponseContent, Headers:
{
Cache-Control: no-cache
Pragma: no-cache
WWW-Authenticate: Negotiate
X-Powered-By: ASP.NET
Date: Fri, 02 Jul 2021 08:30:51 GMT
Content-Type: application/json; charset=utf-8
Expires: -1
Content-Length: 68
}
Is there anything else I missed in the .Net Core version?

Blazor Windows Authentication on Kestrel works locally only? An anonymous request was received in between authentication handshake requests

I created a Blazor application with Windows authentication and hosting with Kestrel/Negotiate following the steps. (https://learn.microsoft.com/en-us/aspnet/core/security/authentication/windowsauth?view=aspnetcore-3.0&tabs=visual-studio#kestrel)
Create Blazor app with Windows Authentication
Create a Blazor application using Visual Studio 2019 (16.4.0). (Windows Authentication, https)
Support Windows Authentication using Negotiate and Kerberos
Following the steps to make all work when running using Kestrel.
Import NuGet package Microsoft.AspNetCore.Authentication.Negotiate
Add the following code in ConfigureService() in Startup.cs.
services.AddAuthentication(NegotiateDefaults.AuthenticationScheme).AddNegotiate();
Add the following code in Configure() in Startup.cs. They are added between app.UseRouting(); and app.UseEndpoints(...;
app.UseAuthentication();
app.UseAuthorization();
Windows Authentication not working. Add middleware ValidateAuthentication
It still doesn't work with Windows Authentication until the answer from this question is applied.
Add this in your Configure method:
app.UseMiddleware<ValidateAuthentication>();
Here is the middleware itself:
internal class ValidateAuthentication : IMiddleware
{
public async Task InvokeAsync(HttpContext context, RequestDelegate next)
{
if (context.User.Identity.IsAuthenticated)
await next(context);
else
await context.ChallengeAsync();
}
}
And in ConfigureServices :
services.AddSingleton<ValidateAuthentication>();
Now it works on the local PC.
And the following code is added to CreateHostBuilder() in Program.cs for remotely.
webBuilder.UseUrls(new string[] { "https://*:5001", "http://*:5000" });
Not work on another computer!
However, it pops up a window for the user name/password (it's Windows authentication and shouldn't ask for it again) and gets the following error on my company computer.
When trying at home PCs, it just shows the following message without popup window for username/password.
The output window shows
Request starting HTTP/1.1 GET https://mymachinename:5001/
info: Microsoft.AspNetCore.Authentication.Negotiate.NegotiateHandler[0]
None
info: Microsoft.AspNetCore.Authentication.Negotiate.NegotiateHandler[1]
Incomplete Negotiate handshake, sending an additional 401 Negotiate challenge.
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
Request finished in 5.3618ms 401
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
Request starting HTTP/1.1 POST https://MyMachineName:5001/_blazor?id=5PKkHuIU8OTq2i8tGbkP0A text/plain;charset=UTF-8 3
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0]
Executing endpoint '/_blazor'
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1]
Executed endpoint '/_blazor'
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
Request finished in 5.6983ms 200 text/plain
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
Request starting HTTP/1.1 POST https://MyMachineName:5001/_blazor?id=5PKkHuIU8OTq2i8tGbkP0A text/plain;charset=UTF-8 3
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0]
Executing endpoint '/_blazor'
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1]
Executed endpoint '/_blazor'
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
Request finished in 5.331ms 200 text/plain
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
Request starting HTTP/1.1 GET https://MyMachineName:5001/
fail: Microsoft.AspNetCore.Authentication.Negotiate.NegotiateHandler[5]
An exception occurred while processing the authentication request.
System.InvalidOperationException: An anonymous request was received in between authentication handshake requests.
at Microsoft.AspNetCore.Authentication.Negotiate.NegotiateHandler.HandleRequestAsync()
fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
An unhandled exception has occurred while executing the request.
System.InvalidOperationException: An anonymous request was received in between authentication handshake requests.
at Microsoft.AspNetCore.Authentication.Negotiate.NegotiateHandler.HandleRequestAsync()
at Microsoft.AspNetCore.Authentication.Negotiate.NegotiateHandler.HandleRequestAsync()
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
Request finished in 80.1697ms 500 text/html; charset=utf-8
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
Request starting HTTP/1.1 POST https://MyMachineName:5001/_blazor?id=5PKkHuIU8OTq2i8tGbkP0A text/plain;charset=UTF-8 3
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0]
Executing endpoint '/_blazor'
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1]
Executed endpoint '/_blazor'
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
Request finished in 11.6024ms 200 text/plain
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1]
Executed endpoint '/_blazor'
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
Request starting HTTP/1.1 POST https://MyMachineName:5001/_blazor?id=5PKkHuIU8OTq2i8tGbkP0A text/plain;charset=UTF-8 3
I got the prompt when capturing the network traffice
Session #13: The server (us005) presented a certificate that did not validate, due to RemoteCertificateNameMismatch, RemoteCertificateChainErrors.
0 - A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
SAN: localhost
SUBJECT: CN=localhost
ISSUER: CN=localhost
This warning can be disabled by clicking Tools > Options.
It asks for username/password after I chose ignore the warning. Why it asks for username/password?
The sessions before popup the username/password:
GET https://us005:8091/ HTTP/1.1
Host: us005:8091
Connection: keep-alive
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36
Sec-Fetch-Mode: navigate
Sec-Fetch-User: ?1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3
Sec-Fetch-Site: none
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
HTTP/1.1 401 Unauthorized
Date: Fri, 06 Dec 2019 23:11:38 GMT
Server: Kestrel
Content-Length: 0
WWW-Authenticate: Negotiate
Strict-Transport-Security: max-age=2592000
Proxy-Support: Session-Based-Authentication
------------------------------------------------------------------
GET https://us005:8091/ HTTP/1.1
Host: us005:8091
Connection: keep-alive
Cache-Control: max-age=0
Authorization: Negotiate YIIUvQYGKwYBBQUCoIIUsTCCFK2gMDAuBgkqhkiC9xIBAgIGCSqGSIb3EgECAgYKKwYBBAGCNwICHgYKKwYBBAGCNwICCqKCFHcEghRzYIIUbwYJKoZIhvcSAQICAQBughReMIIUWqADAgEFoQMCAQ6iBwMFACAAAACjghJtYYISaTCCEmWgAwIBBaETGxFHQkwuQUQuSEVEQU5JLk5FVKIwMC6gAwIBAqEnMCUbBEhUVFAbHXVzd2xscHJpMDA1LmdibC5hZC5oZWRhbmkubmV0o4ISFTCCEhGgAwIBEqEDAgE/ooISAwSCEf8SPyfVTTIyEghWZnkJmimTadjkmX2k7PMXqFzw5igbGi0rxsNo9kBfA7dXq1NrSCgXDM5moPXdON//Tr6FjxeSkgPd7CTgZCsg8/65iMbkcK9QcbP7taholjBVJDNF810PrsS7jLsIPodS7frM4KTGSXTfrItoCXt0HwVhhQnF81ajnV/MIKoUokDJtJVRlGKurK078JM2Wvik6JAkgj35Xstr4rEbgs6a4SnYGBKiIpFErnNOmYZyL8LyZ4RS09UwJ9jboMIHmKOTG/8ZwuKHoA8G1I/lFc44xoKnz9OqboYr6x9UsnooIZAgYxZ43oO1P+B6xwwu7qgOFPSSW+GSJdErlQYKJP5L9CI1d+jJhgnw9bxqVBT30B055DQYyM0UXWTwHx8TeyIf2rhVsqtvxpiEVXx1F6zB9IpU9770fu4orK6IDowTGOxGuYexl39kdfpweJarJjSQ7cmXOrs7FnZHUVgR6N+OpEoRExAoNEfgqjDE5+HlhbXQ7FQSkOHXN82bdEzSM9ER4EvHCK25vycKyNmyTpwwdC3qSnF6HKYKRAlUt+j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JVpEgA+LfX5x2sw3zs8RvBY/Ul8htlY1hnilvmWSRfJd+NHvXQVTng4z9lQV2odUKDIFkiL++wg4zJq+R0XgKfqm6SUmhZu5OJ+jYwsOgOOL1mhD0qP1/Bfy/PZV52NXJ1w4qc+O+afY7HvV43V02Y82/IqZ6SCAdIwggHOoAMCARKiggHFBIIBwSS4hy3oR17Czx0xy9V2qFSCcgYkEm4KET9Jr9JzG+j/gmsNM7ZKBPu/hZEXeDf/Mmw7P36iWwXvm+UcRMfvnMg10Mxo1tAVgUc0JXiBCFyOfTIfkenUmFfN25TP72NgibBMnwSzI5BubaI0VMFwUwoG4UPwt3K98gLLQ6sLZ3G6mbKn9NHOjNktuK+QkK/JzK6TLopduWbhUH/oQFvNPIVyoO3zau0LNKj+RG0DXTKeMlSD7RsK8W/V1nzVL83AjxUbunzbo9PvYGBvgHlnZys+ssc7Cuv8y1Q/IEie8XLeKLob0GyyU2DH+ObzGEwg3H+cs/vto7RJYPKNmIz03BkTm4t737h2l+XN8U3zrCeVERojst8edwbLrbOR3lFC7g43gdF1TnIDGwA4xjM4G7GcTsHfpR9HqHchkmccwWQ9/quoJuzO6zYuLuWG9cIh2AgYM2w1ghEYfz9bdIc7wY9vNNFp0P9glOamEQplg5DBLd24udA111d6o/V+1ht9v4vaGmArg+gHqoinHxlo4+eugjMYHlswdBqCU+2Ssk1hRM+yyQXzN9MMP2a9LPqd6pSwp4VjbfN38r5dkR+nzgUN
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36
Sec-Fetch-Mode: navigate
Sec-Fetch-User: ?1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3
Sec-Fetch-Site: none
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
HTTP/1.1 401 Unauthorized
Date: Fri, 06 Dec 2019 23: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Iry9AZ2bQh0eu4mVzVJ4q7wHq/PgTsIQzhHlhnkf6xkZXie8y62anM6z8dzQoTXbQPhvSg9QfEsOchmBjlGJmofPt9yZr/HQ9eGk2bncNKkh8sBNyShEcFt0jQbANkD9X1izM3zN3gBqJox8FLi1egCvyH98lU/Stx8dHFmT4/nnGhpZuW+Qig+aSU3jCgcKIJshWTqSGjSbQc/AC4TYiBqn8z+X6fLDzQ5y/Q4oyilC0JKfGLqopXQJJOlE7OEA21KuzqzmJuma1E9QQ4PABndykDA7PcGgTZrbCKrOqxPeE6FH6mv54LfPlXrmrzb7BtIiLhuPaaCQME/fRwPwoWEwcwv9aiihSJ8Ot7kd2hxCTtVMi/ce8NjH4uGaRrLh+TQr+OVPWXPbie/Y8mQnK290BZ23I8S/VJhUcog8v99A9GtRS9IpXrOan/Mt9Gyqax1rJiQSmRJJkulXZ5gD/8lneMkJdz0q9/PWb6jtF10Fx00bOv72NDo9S5Q6TGZXBDca2bZFi5TeGQhL/2kg1LkHuMgCb2B5dDCxFJV+a77UFqFEtjOg5jobDDHaDA2Rfbgxh9q74Es+Ix7CG0ByZhdkvtAG5x1ri741hQMgtnD55IAM9FYQuen39ET3epXqYMy/nAZat090C/AT/swsE/B6tFv22iS4NQ0ckarQJ206ylZFcEwUOhhllXixvIdH5UG73IsCrFMUU=
Strict-Transport-Security: max-age=2592000
Proxy-Support: Session-Based-Authentication
------------------------------------------------------------------
GET https://us005:8091/ HTTP/1.1
Host: us005:8091
Connection: keep-alive
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36
Sec-Fetch-Mode: navigate
Sec-Fetch-User: ?1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3
Sec-Fetch-Site: none
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
HTTP/1.1 401 Unauthorized
Date: Fri, 06 Dec 2019 23:11:38 GMT
Server: Kestrel
Content-Length: 0
Cache-Control: no-cache
Pragma: no-cache
Expires: -1
WWW-Authenticate: Negotiate
Strict-Transport-Security: max-age=2592000
Proxy-Support: Session-Based-Authentication
This is not supported by design unfortunately.
See post here:
https://github.com/dotnet/aspnetcore/issues/13124
I had a similar issue. Negotiate seems to default to NTLM when running on localhost, but Kerberos over a DNS name. Kerberos requires a SPN. I fixed it by adding the correct SPN using:
setspn -D HTTP/hostname serviceAccountName
The exact SPN will vary depending upon your setup.

Blob type of the blob reference doesn't match blob type of the blob

I have code to check for the existence of a blob and its size that works fine in my development machine but when I publish to the production server it gives me the exception:
Blob type of the blob reference doesn't match blob type of the blob
Here is the code:
CloudStorageAccount v_StorageAccount = CloudStorageAccount.Parse(v_ConnectionString);
CloudBlobClient v_BlobClient = v_StorageAccount.CreateCloudBlobClient();
CloudBlobContainer v_Container = v_BlobClient.GetContainerReference(v_Containerstring);
CloudBlockBlob v_Blob = v_Container.GetBlockBlobReference(p_Name);
v_Blob.FetchAttributes();
I have tested around with fiddler and found out that when running in the server, the response header does not have any of the x-ms- tags, although the request headers are identical in both machines.
Request Header:
HEAD http://XXX/90f5a5f1-9f6f-46bc-bbf6-21d77b8955ed HTTP/1.1
User-Agent: Azure-Storage/8.2.0 (.NET CLR 4.0.30319.36399; Win32NT 6.2.9200.0)
x-ms-version: 2017-04-17
x-ms-client-request-id: XXX
x-ms-date: Thu, 11 Jan 2018 13:44:14 GMT
Authorization: SharedKey XXX:XXX
Host: XXX
Response in development machine:
HTTP/1.1 200 OK
Content-Length: 504014
Content-Type: application/octet-stream
Content-MD5: /i5aFVWYlPqZjHvU+gxcbw==
Last-Modified: Wed, 13 Dec 2017 20:22:02 GMT
Accept-Ranges: bytes
ETag: "0x8D542672BB913FD"
Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
x-ms-request-id: 04155a59-001e-000d-58e5-8ab906000000
x-ms-version: 2017-04-17
x-ms-lease-status: unlocked
x-ms-lease-state: available
x-ms-blob-type: BlockBlob
x-ms-server-encrypted: false
Date: Thu, 11 Jan 2018 14:04:56 GMT
Response in production server:
HTTP/1.1 200 OK
Content-Length: 504014
Content-Type: application/octet-stream
Content-MD5: /i5aFVWYlPqZjHvU+gxcbw==
Last-Modified: Wed, 13 Dec 2017 20:22:02 GMT
Accept-Ranges: bytes
ETag: "0x8D542672BB913FD"
Server: Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0
Date: Thu, 11 Jan 2018 13:44:14 GMT
I don't know what I'm missing here, but, most important, how to make this code work on the production server?
Edited
To clarify some aspects:
Development machine: my notebook with windows 10 + visual studio 2017
Production server: virtual machine with windows server 2012 standard + sql server standard (no visual studio) + .net framework 4.5 enabled (project is 4.5)
The server is on-premises, local, on the same network as my machine
Using nuget package WindowsAzure.Storage 8.7
All calls are to the same storage account and same Blob object, no emulator involved
The exception occurs at call to v_Blob.FetchAttributes().
The same exception occurs also if I call v_Blob.Exists().
I'm sure the blob is a Block Blob, the two calls (one from my development machine and other from production server) are to the same account and same Blob object, with the exact same parameters (connection string, container string and blob name). In my development machine all works fine.
Stack trace from exception:
at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](RESTCommand`1 cmd, IRetryPolicy policy, OperationContext operationContext) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Core\Executor\Executor.cs:line 604
at Microsoft.WindowsAzure.Storage.Blob.CloudBlob.FetchAttributes(AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Blob\CloudBlob.cs:line 1619
at AzureDataMigration.Class.ConfereDocsMigrados.createBlockBlob(String p_Name, Int64 p_IdCompany, Int64 p_IdDocumentConfigType, StorGlobalHistoricalDocsEntities p_Model)
at AzureDataMigration.Class.ConfereDocsMigrados.Confere()

Why does IIS return empty responses?

I just published an AngularJS/WebAPI project using File system publish to a local IIS Application and I can open the website in my browser. Unfortunately, no resources such as images, css etc. can be loaded. When I try to reach any file located in a sub folder I still receive a HTTP 200 from the server, but the body is empty. I can remember I´ve had this issue a few years back but I can´t remember why this happens.
Request
GET http://localhost/Content/images/common/logotype.png HTTP/1.1
Host: XX.XXX.XX.XXX
Connection: keep-alive
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.130 Safari/537.36
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-US,en;q=0.8,sv;q=0.6
Response
HTTP/1.1 200 OK
Server: Microsoft-IIS/8.5
X-Powered-By: ASP.NET
Date: Tue, 25 Aug 2015 07:56:12 GMT
Content-Length: 0
As you can see, there is no body at all but the image exists in the folder and I can open it from the filesystem. I would guess that if this was a privilege issue the server would return 403 or a similar error, not 200 OK?
Facepalm
Turns out that Lex Li:s comment put me in the right direction. I had completely missed to include the "Static Content" feature was missing in IIS "Common HTTP Features".

Browser seems to ignore caching headers

When an image is requested to my ASP.NET application, my C# code responds with the binary data in addition to the following headers (as capture in Fiddler):
HTTP/1.1 200 OK
Cache-Control: public
Content-Type: image/jpeg
Expires: Fri, 06 Sep 2013 21:43:21 GMT
Last-Modified: Wed, 04 Sep 2013 22:21:27 GMT
ETag: "0x8D0770B10F6F56D"
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Fri, 06 Sep 2013 21:13:23 GMT
Content-Length: 39007
My expectation is that the browser will cache this image until at least 21:43 GMT (which is 30 minutes from now) but that's not what happens. When I press F5, my browser sends another request for the image to my ASP.NET application.
What is missing from my headers to ensure the file is properly cached?

Categories

Resources