Visual Studio 2022 has a built-in HTTP file editor. You can keep requests beside an ASP.NET Core
project, click Send Request, and inspect the response without first creating a Postman
collection. The useful part is not merely the editor: the request remains a plain .http file
that Git, code review, and other compatible tools can understand.
Microsoft documents the editor for Visual Studio 2022 17.8 and later with the ASP.NET and web
development workload. It recognizes both .http and .rest files. The steps below use the
portable core of the format first, then call out Visual Studio-specific additions.
Create and send the first request
Add an HTTP File to the project, or create a text file named api.http. Put the method and URL
on the first line:
GET https://localhost:7042/weatherforecast
Accept: application/json
Run the API if the URL points to localhost. Visual Studio shows a Send Request link above the method line; select it and the response opens beside the editor.
Separate multiple requests with ###:
@baseUrl = https://localhost:7042
GET {{baseUrl}}/weatherforecast
Accept: application/json
###
POST {{baseUrl}}/orders
Content-Type: application/json
{
"sku": "KARVE-001",
"quantity": 2
}
The @baseUrl declaration, {{baseUrl}} reference, request lines, headers, body, and ###
separator form a useful portable subset. Karve, the VS Code REST Client, and JetBrains HTTP Client
all understand the same basic shape, although advanced features differ between tools.
Generate requests from Endpoints Explorer
For an ASP.NET Core API, open View → Other Windows → Endpoints Explorer. Visual Studio discovers
routes and can generate a request into the project's .http file. This is convenient for getting
the path and method right, but the generated request is still ordinary text—rename it, add realistic
headers and bodies, and review it like any other test asset.
Keep generated requests small. One file per service or bounded feature is easier to navigate than a single file containing every endpoint in a large application.
Use variables without committing secrets
Visual Studio supports file variables and can read values through its $processEnv and $dotenv
helpers. Microsoft explicitly warns that .env files might not be ignored by source control by
default. Add secret-bearing files to .gitignore before adding real tokens.
@baseUrl = https://localhost:7042
GET {{baseUrl}}/me
Authorization: Bearer {{$dotenv API_TOKEN}}
That $dotenv expression is Visual Studio-specific. If you want the same file to run in Karve,
reference a normal variable instead:
GET {{baseUrl}}/me
Authorization: Bearer {{token}}
Then keep baseUrl and token in Karve's selected .env environment. File-level @var values win
when both sources define the same name. This keeps the request readable and the secret outside it.
A practical project layout
src/
Orders.Api/
Orders.Api.csproj
requests/
orders.http
health.http
local.env.example
.gitignore
Commit the .http files and a redacted environment example. Ignore the real local environment.
This layout keeps executable examples near the solution without hiding them inside IDE settings.
Where Visual Studio ends and Karve begins
Visual Studio is excellent when the request belongs to the solution already open in the IDE. Karve becomes useful when request files are spread across several repositories or you want a dedicated response viewer and searchable history without keeping every solution open.
The files do not need to move. Open or collect the existing .http and .rest paths in Karve,
select a .env environment, and run from the method line. Continue editing the same files in Visual
Studio whenever that is the better context.
Common problems
- No Send Request link: confirm Visual Studio is 17.8 or later and the web workload is installed.
- Localhost refuses the connection: run the API and confirm the port in
launchSettings.json. - A variable is unresolved: check which tool-specific environment syntax the file uses.
- A token appears in Git: rotate it immediately, remove it from history, and move future values into an ignored environment file or secret store.
- The file works in one client only: reduce it to the portable request line, headers, body,
###, and ordinary variables, then reintroduce tool-specific features intentionally.
Primary reference
Microsoft Learn: Use .http files in Visual Studio 2022.
For the cross-tool overview, see five ways to run .http files on Windows,
or the Karve vs Visual Studio HTTP files comparison
for the product side.