user3110458
user3110458

Reputation: 374

Asp.net MVC frontend and Asp.NET Web.api backend

Im currently learning Asp.NET as far i understand multitier is the best to write webapps.

so I have 2 projects 1 for the Web Api(backend) and other for the Views (frontend)

My Web Api is working nice but when it comes to my frontend i got an little issue. How can I fetch the JSON string in my controller and is it really right how i do it?

    <form id="form1" method="get" action="http://mywebsite.com/test" >
    <div class="modal fade" id="login-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
        <div class="modal-dialog">
            <div class="loginmodal-container">
                <h1>Login</h1><br>

                <input type="text" name="Name" placeholder="Username">
                <input type="password" name="Password" placeholder="Password">
                <input type="submit" name="login" class="login loginmodal-submit" value="Login">


                <div class="login-help">
                    by Dominic
                </div>
            </div>
        </div>
    </div>
</form>

when I try to test it I get "Website could not be shown"

Upvotes: 1

Views: 2749

Answers (2)

Uday Kalgaonkar
Uday Kalgaonkar

Reputation: 1

The concept of launching Web API is to completely segregate the Views and Controller . Usual way of interacting with API Controller is using Jquery which is easily extendable and since you are doing it from the client script it is incredibly fast

If you mean you want to get the data in your API Controller . Then you need to call that Api Controller Action Method using $.ajax and you need send the data from front end as a parameter .

This is a great resource for you .

Sending JSON object to Web API

Upvotes: 0

Related Questions