Yes, you can use the JS API with any server side platform.
This might be off topic of this forum. Here are some high level steps.
1. create a http handler with asp.net responding to a URL. take a look at system.web.IhttpHandler interface in the asp.net lib.
2. use esri.request to send the query to the http handler, which returns a response with the results.
3. handle the result on client once the results are back.