मैंने कुछ पिछले प्रश्नों को समस्याओं के साथ मदद के लिए कहा है क्योंकि मैंने एमवीसी 4 वेबपी बीटा को आरसी में अपडेट किया है। मुझे अब क्रम में सबसे अधिक मिला है, लेकिन यहां एक है कि मैं अभी तक कारण नहीं समझ सकता।सरल नियंत्रक जो POST लेता है
इस सरल नियंत्रक के लिए मेरे पास एक पोस्ट है जो एक स्वीकार करता है और जो स्वीकार करता है। जब मैं HTML फॉर्म से अनुरोध भेजकर उनको चलाने का प्रयास करता हूं, तो केवल GET नियंत्रक पाया जाता है जबकि POST एक मुझे निम्न त्रुटि लौटाएगा।
{
"Message": "No HTTP resource was found that matches the request URI 'http://localhost/webapi/api/play/test'.",
"MessageDetail": "No action was found on the controller 'Play' that matches the name 'test'."
}
पोस्ट नियंत्रक क्यों नहीं मिला है?
नियंत्रकों
public class PlayController : ApiController
{
[HttpPost] // not found
public string Test(string output)
{
return output;
}
[HttpGet] // works
public string Test2(string output)
{
return output;
}
}
HTML प्रपत्र
<form action="http://localhost/webapi/api/play/test" method="post">
<input type="text" name="output" />
<input type="submit" name="submit" />
</form>
<form action="http://localhost/webapi/api/play/test2" method="get">
<input type="text" name="output" />
<input type="submit" name="submit" />
</form>
यदि मैं 3 साल बाद चिल्ला सकता हूं, धन्यवाद !! इसने एक मुद्दा हल किया जिसे मैंने बस घंटों तक बिताया। यह वही है जो SO के बारे में है। –
मुझे वही त्रुटि मिली जब मेरे पास webApiConfig.cs और नियंत्रक की प्रक्रिया के बीच पैरामीटर नाम मेल नहीं था। –