0

Good Afternoon all,

I'm going to apologize in advance, I am really confused on this subject and also do not exactly know how to ask for help on this topic.

To begin, I am creating a server-less web application using awssdk 2.1. This package came with a great template for the web application but upon creation it does not have a home controller, or any controller(s). Default , I have a folder called Pages inside I had the below files

_ViewStart.cshtml

@{
Layout = "_Layout";
}

_Layout.cshtml

<html> ..
. 
RenderBody();
. 
</html> 

and your standard index.cshtml file

I created another view named Contact, stored the file in the Pages folder. My project can successful navigate and render the Contact.cshtml file. I was already familiar with MVC on .netframework so the work around wasn't to bad . I used this line to control navigation within my project

  <div class="unit-body"><a asp-page="/Contact">Contact</a></div>

The contact page contains a form and a button, I would like to user the information from the form and a function that would send a email. I created the "Home" Controller and within the Contact Method added my logic to fire off the email. However, I never executes any code from my controller. I doesn't even know it exists.

 <div class="col-xl-6 col-md-8 col-12">
      @using (Html.BeginForm())
            {
                <div class="form-wrap">
                    <label class="form-label" for="contact-name">Name<span class="req-symbol">*</span></label>
                    <input class="form-input" id="contact-name" type="text" name="name">
                </div>
                <div class="form-wrap">
                    <label class="form-label" for="contact-phone">Phone<span class="req-symbol">*</span></label>
                    <input class="form-input" id="contact-phone" type="text" name="phone">
                </div>
                <div class="form-wrap">
                    <label class="form-label" for="contact-email">E-Mail<span class="req-symbol">*</span></label>
                    <input class="form-input" id="contact-email" type="email" name="email">
                </div>
                <div class="form-wrap">
                    <label class="form-label label-textarea" for="contact-message">Message<span class="req-symbol">*</span></label>
                    <textarea class="form-input" id="contact-message" name="message"></textarea>
                </div>                   
                <div class="form-button group-sm text-center text-lg-left">                        
                    <button class="button button-primary" @Html.ActionLink("Send", "Contact", "Home", new { @body = "test" })></button>
                </div>


            }
        </div>

Without the use of the controller I have no way to pass the values around to execute my process. I also scoured all the files within the project and cannot find any configuration files to I might be able to set my own HomeController.

If someone could explain or point me in the right direction to begin understanding what/how is rendering my pages.

OR

If someone could help by providing a solution, or resources on how I could pass parameter values without a controller.

  • https://exceptionnotfound.net/razor-pages-how-does-it-differ-from-mvc-in-asp-net-core/ – King Solomon Nov 13 '19 at 02:48
  • I did some more digging and found the link above.. apparently razor pages act as the controller themselves in netcore. I was under the impression that they behaved the same as they do netframework. – King Solomon Nov 13 '19 at 02:51

0 Answers0