Please use the attributes from the System.Web.Http namespace on your WebAPI actions:
[System.Web.Http.AcceptVerbs("GET", "POST")] [System.Web.Http.HttpGet] public string Auth(string username, string password) {...}
The reason why it doesn’t work is because you were using the attributes that are from the MVC namespace System.Web.Mvc
. The classes in the System.Web.Http
namespace are for WebAPI.
Related Posts:
- How to fix No connection could be made because the target machine actively refused it 127.0.0.1:64527
- WCF vs ASP.NET Web API
- Why should I use IHttpActionResult instead of HttpResponseMessage?
- Authorization has been denied for this request – New Web API Project
- Effectively use async/await with ASP.NET Web API
- A potentially dangerous Request.Path value was detected from the client (*)
- .Net 4.8 Support for Windows 10 ends in 26 days?
- How do I generate a random int number?
- What is a NullReferenceException, and how do I fix it?
- How do I get a random YouTube video with the YouTube API?
- What is a NullReferenceException, and how do I fix it?
- CS0120: An object reference is required for the nonstatic field, method, or property ‘foo’
- What is the difference between declarative and imperative paradigm in programming?
- Could not load file or assembly or one of its dependencies
- Group by in LINQ
- Adding values to a C# array
- C# An established connection was aborted by the software in your host machine
- OnCollisionEnter() not working in Unity3D
- Difference between virtual and abstract methods
- How to open .dll files to see what is written inside?
- how does Request.QueryString work?
- C# Java HashMap equivalent
- System.Net.Http: missing from namespace? (using .net 4.5)
- Windows .NET API / Windows 7 / Bluetooth communication with Intel Curie Arduino / Genuino 101
- WFP Grid: MouseRightButtonDown firing occuring BEFORE SelectionChanged on grid. Causing syncing issue
- Can’t add script component because the script class cannot be found?
- ASP.NET Core Dependency Injection error: Unable to resolve service for type while attempting to activate
- ‘do…while’ vs. ‘while’
- Visual Studio /**/ comment shortcut?
- Unable to resolve service for type while attempting to activate
- Best way to generate a random float in C#
- Check if list is empty in C#
- What does the %= operator do? [duplicate]
- What does vary:accept-encoding mean?
- What is clr.dll on .Net framework and what does it do?
- what is this oleaut32.dll?
- How can I secure passwords stored inside web.config?
- Why not use Html.EditorForModel()
- Visual Studio says “Method must have a return type”
- How to Use TextureBrush for painting an Image
- C# compiler error: “not all code paths return a value”
- How do I read and parse an XML file in C#?
- How to fix “namespace x already contains a definition for x” error? Happened after converting to VS2010
- How do I create a Shared Code project (.shproj)
- OnCollisionEnter2D not being executed?
- Is there an exponent operator in C#?
- The calling thread cannot access this object because a different thread owns it
- How can I export data to an Excel file
- Convert JSON String To C# Object
- How can I fix Visual Studio 2015 exception Microsoft.vshup.server.httphostx64.exe has stopped working when run project
- IEnumerable vs List – What to Use? How do they work?
- How to convert code from C# to PHP
- Index was out of range. Must be non-negative and less than the size of the collection parameter name:index
- Is dependency injection useful in C++
- Parse Json string in C#
- System.BadImageFormatException: Could not load file or assembly
- Convert integer to binary in C#
- HTML.ActionLink method
- Could not load file or assembly ‘Microsoft.Web.Infrastructure,
- Thread-safe List
property - Where to place native DLL to use Pocket PC emulator?
- What is the purpose of the vshost.exe file?
- System.ComponentModel.Win32Exception: Access is denied Error
- Excel “External table is not in the expected format.”
- MSSQL Error ‘The underlying provider failed on Open’
- An object reference is required to access a non-static member
- Task vs Thread differences
- There is no ViewData item of type ‘IEnumerable
‘ that has the key country - C# – Rounding Down to Nearest Integer
- How to update the value stored in Dictionary in C#?
- How to write a comment in a Razor view?
- Finalize vs Dispose
- Checking if a string array contains a value, and if so, getting its position
- How to download a file from a URL in C#?
- Substring index and length must refer to a location within the string
- Difference between Method and Function?
- Calculate a MD5 hash from a string
- The model item passed into the dictionary is of type .. but this dictionary requires a model item of type
- How can I get the active screen dimensions?
- WebException (Status: Protocol Error)
- How to add a new row to datagridview programmatically
- Unexpected character encountered while parsing value
- Embedded statement cannot be a declaration or labeled statement
- MailMessage.To.Add() throwing exception : “An invalid character was found in the mail header: ‘,’.”
- Remove duplicates from a List
in C# - How to deserialize xml to object [duplicate]
- How can we prepend strings with StringBuilder?
- C# conditional operator error Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement
- Cannot drop database because it is currently in use
- Troubleshooting “program does not contain a static ‘Main’ method” when it clearly does…?
- Unity 5.2.2 changing Visual Studio back to MonoDevelop
- Using FolderBrowserDialog in WPF application
- How to make Check Box List in ASP.Net MVC
- Is there an equivalent to the C# “var” keyword in C++/CLI?
- The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required?
- Playing a MP3 file in a WinForm application
- Quickest way to compare two generic lists for differences
- What is the easiest way to encrypt a password when I save it to the registry?
- LINQ query on a DataTable
- Memory Leak caused by System.Drawing.Internal.GPStream