简体   繁体   中英

How can I execute php as an post on a MVC C# application?

I have a simple C# asp.net MVC5 project with some bootstrap and other fancy css plugins.

I have little experience with this so I may have missed some basic logic.

So I have this fancy php that will send a styled e-mail to our customers.

The way the view is set up is like this:

<form (...) method="post" action="sendemail.php">

As you can see, it really does not make sence to post to "sendemail.php" in a C# MVC application.

I do, however, want to use the logic set in sendemail.php to send this email. I am not able to map in the sendemail.php to a controller/view (because it only(?) accepts .cshtml).

Anyone have any ideas how I can do this?

This is the complete code in the form on the Contact.cshtml file:

<form id="main-contact-form" class="contact-form" name="contact-form" method="post" action="sendemail.php">
                <div class="col-sm-5 col-sm-offset-1">
                    <div class="form-group">
                        <label>Name *</label>
                        <input type="text" name="name" class="form-control" required="required">
                    </div>
                    <div class="form-group">
                        <label>Email *</label>
                        <input type="email" name="email" class="form-control" required="required">
                    </div>
                    <div class="form-group">
                        <label>Phone</label>
                        <input type="number" class="form-control">
                    </div>
                    <div class="form-group">
                        <label>Company Name</label>
                        <input type="text" class="form-control">
                    </div>                        
                </div>
                <div class="col-sm-5">
                    <div class="form-group">
                        <label>Subject *</label>
                        <input type="text" name="subject" class="form-control" required="required">
                    </div>
                    <div class="form-group">
                        <label>Message *</label>
                        <textarea name="message" id="message" required="required" class="form-control" rows="8"></textarea>
                    </div>                        
                    <div class="form-group">
                        <button type="submit" name="submit" class="btn btn-primary btn-lg" required="required">Submit Message</button>
                    </div>
                </div>
            </form> 

This is very simple, because after all it is all about a POST request.

It does not matter what the post server side programming language is.

Simply post your request to the PHP script, then redirect it back to your MVC application.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM