Can not get [HttpPost] response - c#

just started to learn the ASP MVC, I'm trying to make this form where you give your name and email and .... and when you click on submit Form, it should lead to the "Thanks" page where you see a thanks message and your name.
but after clicking on "Submit" Button nothing happened for me. I want to know what is the problem.
this is the Homecontroller for all action methods
using System;
using Microsoft.AspNetCore.Mvc;
using PartyInvites.Models;
namespace PartyInvites.Controllers
{
public class HomeController : Controller
{
public ViewResult Index()
{
int hours = DateTime.Now.Hour;
ViewBag.Greeting = hours < 12 ? "Good Morning" : "Good Evening";
return View("MyView") ;
}
[HttpGet]
public ViewResult RsvpForm()
{
return View();
}
[HttpPost]
public ViewResult RsvpForm(GuestResponse guestResponse)
{
Repository.AddResponse(guestResponse);
return View("Thanks",guestResponse);
}
}
}
this is "MyView" page , which is the default page
#{
Layout = null;
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width"/>
<title>Index</title>
</head>
<body>
<div>
#ViewBag.Greeting World (from the view)
<p>
We are going to have an exciting party.<br />
(to do:sell it better.Add pictures or something.)
</p>
<a asp-action="RsvpForm"> Ravp Now</a>
</div>
</body>
</html>
}
this is the Form page which you can go there after clicking on Ravp Now
*#
#model PartyInvites.Models.GuestResponse
#{ Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewpot" content="width=device-width"/>
<title>RsvpForm</title>
</head>
<body>
<form asp-action="RsvpForm" method="post"></form>
<p>
<label asp-for="Name"> Your Name: </label>
<input asp-for="Name"/>
</p>
<p>
<label asp-for="Email"> Your Email:</label>
<input asp-for="Email"/>
</p>
<p>
<label asp-for="Phone"> Your Phone:</label>
<input asp-for="Phone"/>
</p>
<p>
<label> Will You Attend?</label>
<select asp-for="WillAttend">
<option value=""> Choose an option </option>
<option value="true"> Yes, I'll be There. </option>
<option value="false"> No, i can't come. </option>
</select>
</p>
<button type="submit"> Submit Rsvp</button>
</body>
</html>
Now the problem is here when I click on Submit Rsvp , Nothing happens.it won't go to the "Thanks" page. I checked all codes a few times but couldn't find anything.
What could be wrong?
these are the "Thanks" View Page and "Repository" class model
#model GuestResponse
#{
Layout = null;
}
<!DOCTYPE html>
<html>
<head >
<meta name="viewport" content="width=device-width"/>
<title>Thanks</title>
</head>
<body>
<p>
<h1> Thank you! #Model.Name!</h1>
#if (Model.WillAttend == true)
{
#:Its great that you're coming.The drinks are already in the Fridge!
}
else
{
#:sorry to here that you can't make it , but thanks for letting us know.
}
</p>
<p> click<a asp-action="ListResponses"> here </a> to see who is coming.</p>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace PartyInvites.Models
{
public static class Repository
{
private static List<GuestResponse> responses=new List<GuestResponse>();
public static IEnumerable<GuestResponse> Responses
{
get { return responses; }
}
public static void AddResponse(GuestResponse response)
{
responses.Add(response);
}
}
}

I think your issue is inside your cshtml file.
All contents of a form must be within such form declaration. I don't have a C# project available to check it right now, but I think the "fixed" code would be something like this:
*#
#model PartyInvites.Models.GuestResponse
#{ Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewpot" content="width=device-width"/>
<title>RsvpForm</title>
</head>
<body>
<form asp-action="RsvpForm" method="post">
<p>
<label asp-for="Name"> Your Name: </label>
<input asp-for="Name"/>
</p>
<p>
<label asp-for="Email"> Your Email:</label>
<input asp-for="Email"/>
</p>
<p>
<label asp-for="Phone"> Your Phone:</label>
<input asp-for="Phone"/>
</p>
<p>
<label> Will You Attend?</label>
<select asp-for="WillAttend">
<option value=""> Choose an option </option>
<option value="true"> Yes, I'll be There. </option>
<option value="false"> No, i can't come. </option>
</select>
</p>
<button type="submit"> Submit Rsvp</button>
</form>
</body>
</html>

Related

Button click in ASP.NET MVC

I am trying to understand how this ASP.NET MVC thing works compared to webforms, so I tried to simply call any method that will do the most basic thing, print some text into console, or change the text of a label.
Turns out it's nearly damn impossible to do, so I tried to look it up, everything I could find requires to first make the method in the controller which can be fine, but then it requires to add the corresponding cshtml file, put some tags over there and when you click that thing you will get the page from the new cshtml, but that's not what I want, an example how it's done from what I was able to find.
In HomeController:
namespace WebApplication9.Controllers
{
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}
public ActionResult About()
{
ViewBag.Message = "Your application description page.";
return View();
}
public ActionResult ClickTest()
{
ViewBag.Message = "ClickTest.";
Debug.WriteLine("Damn...");
return View();
}
public ActionResult Contact()
{
ViewBag.Message = "Your contact page.";
return View();
}
}
}
In Views -> Shared -> _Layout.cshtml
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>#ViewBag.Title - My ASP.NET Application</title>
#Styles.Render("~/Content/css")
#Scripts.Render("~/bundles/modernizr")
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse" title="more options">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
#Html.ActionLink("Application name", "Index", "Home", new { area = "" }, new { #class = "navbar-brand" })
</div>
<div id="test-nav" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>#Html.ActionLink("Home", "Index", "Home")</li>
<li>#Html.ActionLink("About", "About", "Home")</li>
<li>#Html.ActionLink("Click", "ClickTest", "Home")</li>
</ul>
</div>
</div>
</div>
<div class="container body-content">
#RenderBody()
<hr />
<footer>
<p>© #DateTime.Now.Year - My ASP.NET Application</p>
</footer>
</div>
#Scripts.Render("~/bundles/jquery")
#Scripts.Render("~/bundles/bootstrap")
#RenderSection("scripts", required: false)
</body>
</html>
The last step is to add ClickTesty.cshtml in Views -> Home, but that's not at all what I want to do, and all the examples of a click that I was able to find show this approach, except they do other things, but what if I just want to change a label text or hide something on a current page not a new one? I couldn't find any info how to do it using C#, in webforms there's no problem to change some text or hide something on the current page, even using javascript, but here I can't find a way.
To see a Debug.WriteLine in Visual Studio here's what you can do:
Add this code:
<input type="button" value="Click here to debug log" onclick="location.href='#Url.Action("ClickTest", "Home")'" />
Inside the "main" tag on your application
HomeController should look something like this:
public IActionResult ClickTest()
{
Debug.WriteLine("Damn...");
return View("Index");
}
Run the application in Debug mode (F5 by default)
Go to the Home page, click the button 'Click here to debug log'
You will see at the Output pane your Debug.WriteLine
What you are doing right now on your code is to redirect to a different view that doesn't exists. So, returning the View("Index") is doing the trick to not have an error and see your log.

The webpage cannot be found after submit my info

I have view which name is thanks and I want to show this view after click submit , but its encounter with error like this:The webpage cannot be found
Here is my code:
public class HomeController : Controller
{
public ViewResult Index()
{
int hour = DateTime.Now.Hour;
ViewBag.greeting = hour < 12 ? "Good Morning" : "Good Afternoon";
return View ("MyView");
}
[HttpGet]
public ViewResult RsvpForm()
{
return View("RsvpForm");
}
[HttpPost]
public ViewResult RsvpForm(GuestRespons GuestRespons)
{
Repository.AddResponse(GuestRespons);
return View("Thanks", GuestRespons);
}
}
and this is my view :
#{Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>
Thanks
</title>
</head>
<body>
<p>
<h1>
thank you,#Model.Name!
</h1>
#if (Model.WillAttend== true)
{
#:it's great that you are comming.we will see you soon.
}
else
{
#:Sorry to hear that, but Thanks for letting us to know.
}
</p>
<p >
click <a asp-action="ListResponses">here</a> to see who is coming.
</p>
</body>
</html>
And this one is my button which should show thanks view:
#model FuturGoals_partyinvites_.Models.GuestRespons
#{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>RsvpForm</title>
</head>
<body>
<form asp-action="RcvpForm" method="post">
<p>
<label asp-for="Name">Your Name:</label>
<input asp-for="Name" />
</p>
<p>
<label asp-for="Email">Your Email:</label>
<input asp-for="Email" />
</p>
<p>
<label asp-for="phone">Your Phone:</label>
<input asp-for="phone" />
</p>
<p>
<label>Will you come?</label>
<select asp="WillAttend">
<option value="">Choose an option</option>
<option value="true">Yes</option>
<option value="false">No</option>
</select>
</p>
<button type="submit">Submit RSVP</button>
</form>
</body>
</html>
well I don't know how get exception in mvc , I think problem should be with this line:
<button type="submit">Submit RSVP</button>
Thanks in advance.
Your form action attribute value should be a valid url in your app. If you are using the form tag helper, you need to make sure you are passing the valid HttpPost action method name you want to submit to, as the asp-action attribute value.
In your case, your http post action method name is RsvpForm, But in your form you had RcvpForm which is not a valid action method. So fix your form tag helper to use the correct action method and now it should work.
<form asp-action="RsvpForm" method="post">
<!-- Your existing form elements goes here-->
</form>
Do it something like:
<p>
<label asp-for="Name">Your Name:</label>
<input asp-for="Name" />
</p>
<p>
<label asp-for="Email">Your Email:</label>
<input asp-for="Email" />
</p>
<p>
<label asp-for="phone">Your Phone:</label>
<input asp-for="phone" />
</p>
<p>
<label>Will you come?</label>
<select asp="WillAttend">
<option value="">Choose an option</option>
<option value="true">Yes</option>
<option value="false">No</option>
</select>
</p>
<button type="Button" id="submitme" data-url="#Url.Action("RsvpForm","Home")">Submit RSVP</button>
Ajax form like:
$("#submitme").on("click", function () {
var url = $(this).data('url');
$.ajax({
type: 'post',//this can be change to get or post
url: url,
success: function (response) {
if (response != null && response.success) {
Alert("Success");
window.location.href = "/Home/ActionNameHere"; //You can redirect any action name here....
} else {
// DoSomethingElse()
Alert("something wrong");
}
}
});
});

Not Loading Partial View in MVC Application

In my _Layout.cshtml view I have
#using SiteNET.Utilities
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>"SomeTitle"</title>
#Styles.Render("~/Content/css")
#Scripts.Render("~/bundles/modernizr")
<!-- Favicons -->
<link rel="apple-touch-icon-precomposed"
sizes="256x256"
href="#Url.Content("~/Content/Images/SiteRetro256.png")">
<link rel="shortcut icon"
href="#Url.Content("~/Content/Icons/SiteRetro.ico")">
</head>
<body>
<div class="container">
<div class="navbar navbar-default" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<button type="button"
class="navbar-toggle"
data-toggle="collapse"
data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
</button>
#Html.ActionLink(SiteNET.Utilities.Constants.Site,
"Index", "Home", null, new { #class = "navbar-brand" })
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="#Url.MakeActive("Home")">
#Html.ActionLink("Home", "Index", "Home")
</li>
<li class="#Url.MakeActive("Index", "Contacts")">
#Html.ActionLink("Contacts", "Index", "Contacts")
</li>
</ul>
#Html.Action("_LoginPartial", "Account") <- THIS LINE
</div>
</div> <!--container-fluid-->
</div> <!--navbar-->
#RenderBody()
<hr />
...
</div>
</body>
</html>
My aim is be able to load a view model into my _LoginPartial view. So I have added the following to my AccountController class
[ChildActionOnly]
public ActionResult _LoginPartial()
{
ApplicationUser user = null;
ManageUserViewModel model = null;
string userID = User.Identity.GetUserId() ?? String.Empty;
if (!String.IsNullOrEmpty(userID))
{
user = UserManager.FindById(userID);
model = new ManageUserViewModel();
model.IsAdmin = user.IsAdmin;
}
return PartialView(model);
}
But this does not call this method from
#Html.Action("_LoginPartial", "Account")`
I have read this answer and have swapped the
#Html.Action("_LoginPartial", "Account")
to
#Html.Action("_LoginPartial", "Account", new { area = "" })
as the controller is not in the "Shared" folder. I have also tried
#Html.Action("_LoginPartial", "Account", new { area = "Controllers" })`
but I am just getting a browser error:
The page isn't redirecting properly
What am I doing wrong here?
Thanks for your time.
Edit. following #markpSmith's suggestion, I have attempted to use
#{ Html.RenderAction("_LoginPartial", "Account"); }
_but this give the same error. _
Use #Html.Partial("_LoginPartial")
You don't need to specify action in Controller as you can access User.Identity in View so update _LoginPartial with User.Identity instead of Model.
I can't see if you have attempted the:
#Html.RenderPartial()
ActionMethod (see MSDN)
making yours look similar to:
View:
#Html.RenderPartial("_LoginPartial","Account")
Controller:
(within AccountController)
public ActionResult _LoginPartial()
{
ApplicationUser user = null;
ManageUserViewModel model = null;
string userID = User.Identity.GetUserId() ?? String.Empty;
if (!String.IsNullOrEmpty(userID))
{
user = UserManager.FindById(userID);
model = new ManageUserViewModel();
model.IsAdmin = user.IsAdmin;
}
return PartialView(model);
}
Other than that, I would suggest removing the underscore and see if you can run it instead (since it is a partial view, I don't think it will be navigateable anyway)

asp.net mvc client side validation not working?

For some reason my client side validation does not seem to be working:
Here is my html:
#using (Html.BeginForm("Create", "Home", FormMethod.Post))
{
<hr />
#Html.ValidationSummary(true)
<hr />
<p>
<label>Select Client_ID: </label>
<span class="field">
<select name="clientId" id="clientId">
#foreach (var item in Model.ClientId)
{
<option value="#item">#item</option>
}
</select>
</span>
</p>
<p>
<label>#Html.LabelFor(model => model.UserModel.name)</label>
<span class="field">
#Html.EditorFor(model => model.UserModel.name)
</span>
#Html.ValidationMessageFor(model => model.UserModel.name)
</p>
<p>
<label>#Html.LabelFor(model => model.UserModel.password)</label>
<span class="field">
#*<input name="password" id="password" type="password" />*#
#Html.EditorFor(model => model.UserModel.password)
</span>
#Html.ValidationMessageFor(model => model.UserModel.password)
</p>
<p>
<label>#Html.LabelFor(model => model.UserModel.email)</label>
<span class="field">
#*<input name="email" id="email" type="email" />*#
#Html.EditorFor(model => model.UserModel.email)
</span>
#Html.ValidationMessageFor(model => model.UserModel.email)
</p>
<p>
<label>Select: </label>
<span class="field">
<select name="accessLevel" id="accessLevel">
<option value="3">Company</option>
<option value="5">End-User</option>
</select>
</span>
</p>
<input type="submit" value="Submit" />
Here is my model:
public class CreateUserModel
{
[Required]
[Display(Name = "Client_ID")]
public string clientId { get; set; }
[Required(ErrorMessage = "A name is required")]
[MaxLength(20), MinLength(2, ErrorMessage = "Name must be 2 character or more")]
[Display(Name = "Name")]
public string name { get; set; }
[Display(Name = "Email Address")]
[Required(ErrorMessage = "Email is Required")]
[RegularExpression(#"^([a-zA-Z0-9_\-\.]+)#((\[[0-9]{1,3}" +
#"\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\" +
#".)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$",
ErrorMessage = "Email is not valid")]
public string email { get; set; }
[Required]
[MaxLength(20), MinLength(6, ErrorMessage = "Password Must be 6 or more chataters long")]
[Display(Name = "Password")]
public string password { get; set; }
[Required]
public int accessLevel { get; set; }
}
and I do have client side enabled in the webconfig:
<appSettings>
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
{EDIT} added rendered html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Home Page - My ASP.NET Application</title>
<link href="/Content/bootstrap.css" rel="stylesheet"/>
<link href="/Content/site.css" rel="stylesheet"/>
<script src="/Scripts/modernizr-2.6.2.js"></script>
</head>
<body>
<script src="/Scripts/jquery.validate.js"></script>
<div class="jumbotron">
<h1>Add Users to the website</h1>
</div>
<form action="/Home/Create" method="post"> <hr />
<hr />
<p>
<label for="UserModel_name">Name</label>
<span class="field">
<input type="text" name="name" />
</span>
<span class="field-validation-valid" data-valmsg-for="UserModel.name" data-valmsg-replace="true"></span>
</p>
<p>
<label for="UserModel_password">Password</label>
<span class="field">
<input name="password" id="password" type="password" />
</span>
<span class="field-validation-valid" data-valmsg-for="UserModel.password" data-valmsg-replace="true"></span>
</p>
<p>
<label for="UserModel_email">Email Address</label>
<span class="field">
<input name="email" id="email" type="email" />
</span>
<span class="field-validation-valid" data-valmsg-for="UserModel.email" data-valmsg-replace="true"></span>
</p>
<p>
<label>Select: </label>
<span class="field">
<select name="accessLevel" id="accessLevel">
<option value="3">Company</option>
<option value="5">End-User</option>
</select>
</span>
</p>
<input type="submit" value="Submit" />
</form>
<hr />
<footer>
<p>© 2014 - My ASP.NET Application</p>
</footer>
</div>
<script src="/Scripts/jquery-2.1.0.js"></script>
<script src="/Scripts/bootstrap.js"></script>
For some reason the Html helpers does not have generated validation attributes in the inputs (data-val="true" and the others), check that. Besides to check the order in which the javascript libraries are loaded:
<script src="~/Scripts/jquery.js"></script>
<script src="~/Scripts/jquery.validation.js"></script>
<script src="~/Scripts/jquery.validation.unobtrusive.js"></script>
Your problem is likely that you have jQuery at the bottom of your file, but you are putting jquery.validate at the top. jQuery has to come before jQuery.validate. I would suggest always putting jQuery in your header, not in the body, and it should be the first thing after modernizr.
Also, you do know that jQuery 2.x does not work with IE8 ore earlier, right?
It seems that your jquery.validate.js is in wrong position. It must be after main jquery ref.
For MVC 5, it should be as following:
_Layout.cshtml: (bottom of page)
<body>
...
...
#Scripts.Render("~/bundles/jquery")
#Scripts.Render("~/bundles/bootstrap")
#Scripts.Render("~/bundles/jqueryval") <!-- *required for client side validation! -->
#RenderSection("scripts", required: false)
</body>
where ~/bundles/jqueryval is defined in BundleConfig.cs: RegisterBundles() method:
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
"~/Scripts/jquery.validate*"));
Use:
#Html.EditorFor
Instead of:
<input>
And of course you need the jquery.validate.* scripts
TRY THIS: Your validation is failing because you have hard-coded this JQuery link version at the bottom of your page, which likely has been updated to a newer version in your Scripts folder:
<script src="/Scripts/jquery-2.1.0.js"></script>
All you need to do is go to "Scripts", see if there is a "jquery-2.1.0.js" file or you updated JQuery to a newer version. Type in the newer version file name, if found, and retest. It should work now. As of this June 2017 we are on JQuery version 3.1.1
This happened to me and I was pulling my hair out till I realized I had updated JQuery and saw it removed the old version. I bet that's your issue. In case you are not doing this, I recommend you not follow the View Page templates that stick validation scripts in View Pages and instead create a simple usercontrol or masterpage or layout view page and stuff your JQuery links in there so they are shared universally by all project pages. The browser will naturally cache these pages the first time, so even if they aren't used on other pages they are not loaded again.
Not sure if this is being loaded dynamically (e.g loading a partial view with Ajax). If so then you need to parse the html with the validator on the success e.g.
Use something like...
$.validator.unobtrusive.parse(".target");
E.g.
function loadAPartialView(endPoint) {
$.ajax({
url: endPoint,
type: 'GET',
cache: false,
success: function (result) {
$('.target').html(result);
$('.target').show();
// IMPORTANT. Next line is required to get the client side validation to run.
$.validator.unobtrusive.parse(".target");
$(".loadingMessage").hide();
},
error: function (result) {
// Error message...
$(".loadingMessage").hide();
}
});
};

TypeError: chat.send is not a function

So, i am pretty new to SignalR(just started playing with it this week) but havent got it to work yet. Im trying to get a simple chat working in MVC 4 but ive been stuck for some time now, this is what i have so far, any hints or tips would be useful!
The error i currently get with firebug is this:
"TypeError: chat.send is not a function"
Startup.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Microsoft.AspNet.SignalR;
using Owin;
namespace SignalRWebChatVer2
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
var config = new HubConfiguration
{
EnableCrossDomain = true
};
app.MapHubs(config);
}
}
}
ChatHub.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Microsoft.AspNet.SignalR;
using Microsoft.AspNet.SignalR.Hubs;
namespace SignalRWebChatVer2
{
[HubName("ChatHub")]
public class ChatHub : Hub
{
public void Send(string messages)
{
Clients.All.addMessage(messages);
}
}
}
Chat.cshtml
#{
ViewBag.Title = "Chat";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>Chat</h2>
<div>
<input type="text" id="msg"/>
<input type="button" id="broadcast" value="Send"/>
<ul id="messages"></ul>
</div>
_Layout.csthml
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>#ViewBag.Title - My ASP.NET MVC Application</title>
<link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
<meta name="viewport" content="width=device-width" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="#Url.Content("~/Scripts/jquery.signalR-2.0.0-beta2.js")" type="text/javascript"></script>
<script src="#Url.Content("~/signalr/hubs")" type="text/javascript"></script>
</head>
<body>
<script type="text/javascript">
$(function() {
var chat = $.connection.chatHub;
//$.connection.hub.start();
chat.client.addMessage = function(messages) {
$("#messages").append('<li>' + messages + '</li>');
};
$.connection.hub.start().done(function() {
$("#broadcast").click(function() {
//var message = $('#msg').val();
chat.send($('#msg').val());
//chat.server.send(message);
});
});
});
</script>
<header>
<div class="content-wrapper">
<div class="float-left">
<p class="site-title">#Html.ActionLink("your logo here", "Index", "Home")</p>
</div>
<div class="float-right">
<section id="login">
#Html.Partial("_LoginPartial")
</section>
<nav>
<ul id="menu">
<li>#Html.ActionLink("Home", "Index", "Home")</li>
<li>#Html.ActionLink("About", "About", "Home")</li>
<li>#Html.ActionLink("Contact", "Contact", "Home")</li>
<li>#Html.ActionLink("Chat", "Chat", "Home")</li>
</ul>
</nav>
</div>
</div>
</header>
<div id="body">
#RenderSection("featured", required: false)
<section class="content-wrapper main-content clear-fix">
#RenderBody()
</section>
</div>
<footer>
<div class="content-wrapper">
<div class="float-left">
<p>© #DateTime.Now.Year - My ASP.NET MVC Application</p>
</div>
</div>
</footer>
#*#RenderSection("scripts", required: false)*#
</body>
Is there anything more you need to see? If so just hit me up and i will get back ASAP.
Anyway, thanks in advance.
Best regards,
You're executing the "send" function incorrectly.
It should be:
chat.server.send($('#msg').val());
You have that commented out so not sure if you tried it but ^ is the correct way how to execute the send method.
IF that's not the issue you're encountering ensure that you can see your /signalr/hubs in the browser (verify that it generates a javascript file).

Categories

Resources