Reputation: 4209
I have a windows service which accesses a function in an MVC application to do some work.
The only way I was able to allow the service to access the function was by granting anonymous access to the function like this:
[AllowAnonymous]
[HttpPost]
public JsonResult UploadFile(ImportedFileModel uploadedFile)
{
}
I wonder, is there any safer way to do this. I am not convinced that [AllowAnonymous] is a good solution.
Is there anyway I can make the access specific to the Windows Service?
Many thanks.
Upvotes: 0
Views: 204
Reputation: 44700
Expose your function as an web method. If upgrade is an option, you can upgrade your application to ASP.NET MVC 4 and use build in Web API framework.
There are a lot of ways how to manage access to your web methods. Check out for example OAuth.
Good luck!
Upvotes: 2