Issue with routing ASP.Net MVC - asp.net

When I run the application with ISS after clicking on a class.
The browser starts up with this url. http://localhost:50282/
When I click on Index in my folder Account In Views and
run the application I get this url: http://localhost:50282/Account/Index
Now on both urls I have a register form that links to an action
in my AccountController.
When I submit the form in the second case I get this url:
http://localhost:50282/Account/register and the register method is run in my AccountController Class and works fine.
In the first case I get this url and error:
Url: http://localhost:50282/register
Error: 404
Server Error in '/' Application.
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /register
I want the url to go to the second url http://localhost:50282/Account/register
after clicking register no matter where I clicked before running the application.
Submit form view code:
#{
ViewBag.Title = "Index";
}
<h1>Register Form </h1>
<form action="register" method="post">
<label><i class="" aria-hidden="true"></i> Username </label>
<input type="text" name="Username" placeholder="Enter User Name" required="" />
<br>
<label><i class="" aria-hidden="true"></i> password </label>
<input type="password" name="Password" placeholder="Enter Password" required="" id="myInput" />
<input type="submit" value="Register">
</form>

You need to specify where your form is being submitted to. So change this...
<form action="register" method="post">
<label>
<i class="" aria-hidden="true"></i> Username </label>
<input type="text" name="Username" placeholder="Enter User Name" required="" />
<br>
<label>
<i class="" aria-hidden="true"></i> password </label>
<input type="password" name="Password" placeholder="Enter Password" required="" id="myInput" /> <input type="submit" value="Register">
</form>
To a html helper for your form...
#using(Html.BeginForm("Register", "Account"))
{
<label><i class="" aria-hidden="true"></i> Username </label>
<input type="text" name="Username" placeholder="Enter User Name" required="" />
<br>
<label><i class="" aria-hidden="true"></i> password </label>
<input type="password" name="Password" placeholder="Enter Password" required="" id="myInput" />
<input type="submit" value="Register">
}
Also you need to add antiforgery token for security (#html.Antiforgerytoken()). And decorate Register action with [ValidateAntiforgeryToken] attribute.
See this

Related

How to hide form field while reusing same form

I am using the following form to save user information.
<%# taglib prefix="sf" uri="http://www.springframework.org/tags/form"%>
<sf:form action="someAction"method="post" commandName="backingBean">
<sf:input type="hidden" name="userId" path="userId" />
<sf:input type="text" placeholder="Username" name="username" path="username" />
<sf:input placeholder="Password" path="password" type="password" name="password" />
<sf:input placeholder="Email" name="email" type="email" path="email" />
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}" />
<button type="submit" class="btn btn-default">Submit</button>
</sf:form>
When an user want to edit their information I am sending them the same form using hidden userId. But this time I wish not show password filed in the form. How do I do that.
You could try with an <c:choose><c:when.. that tests a condition and does what you want: "not show password filed in the form"

Retrieving a URL via a Wufoo Form

I'm pretty new to using wufoo forms and have been searching for a few days and can't quite find what I'm looking for.
I did find a number of articles about 'URL Modification' but not sure how to implement this for what I need.
We have a simple single wufoo form which is being used across 6 iterations of a client's domains (they are sector specific).
We want (in the email notification and response entry on wufoo) to record which site was used to complete the form (for analytical purposes).
In other words the email to the client should list:
Name: John Smith
Email: Johnsmith#mail.com
Phone: 555-123-1234
From: www.websiteversion1.com
The form is being integrated on Wordpress sites.
Any help would be appreciated!
You can copy the form HTML to your site's templates and modify the form, using PHP to fill in the value of the site url. I don't think WuFoo will automatically fill that field in for you.
First of all, in your WuFoo account forms manager, add a website (url) field and make it visible for admins only (this is a Wufoo option).
Then copy the generated form into your own template.
Now modify your form template so that it grabs the site URL and fills it in for the value of the website field where you want it.
Your form template might look something like this:
<form class="wufoo-form" id="form3" name="form3" accept-charset="UTF-8" autocomplete="off" enctype="multipart/form-data" method="post" novalidate action="#">
<div class="form-group">
<label for="Field1">Name</label>
<input id="Field1" name="Field1" type="text" placeholder="" value="">
</div>
<div class="form-group">
<label for="Field2">Email</label>
<input id="Field2" name="Field2" type="email" placeholder="" value="">
</div>
<div class="form-group">
<label for="Field3">Phone</label>
<input id="Field3" name="Field3" type="tel" placeholder="" value="">
</div>
<div class="form-group hidden">
<label for="Field4">From</label>
<input id="Field4" name="Field4" type="url" class="form-control" placeholder="" value="<?php esc_url( home_url() ); ?>">
</div>
<div class="form-group">
<button id="saveForm" name="saveForm" type="submit" name="submit" class="btn btn-primary btn-lg">Let's talk!</button>
<input type="hidden" id="idstamp" name="idstamp" value="***the_id_for_your_form_wufoo***" />
</div>
</form>

MailChimp for WordPress Redirect

I'm using the MailChimp for WordPress plugin and would like to re-direct to a new page on submit if possible?
Here's the code I've been trying to use:
<p>
<label>Name:</label>
<input type="text" required="required" placeholder="Your name" name="FNAME">
</p>
<p>
<label for="mc4wp_email">Email address: </label>
<input type="email" id="mc4wp_email" name="EMAIL" placeholder="Your email address" required />
</p>
<p>
<input type="submit" value="Sign up" />
<input type="hidden" name="redirect" value="/test">
</p>
I've tried adding that hidden input to re-direct but it hasn't worked from me, would appreciate any help! Thanks!
Did you forget to look at the plugin settings?
Navigate to Mailchimp for WP > forms, scroll down to "Redirect to URL after successful sign-ups".

Can i have two action servlets in an html form?

<form action="LoginServlet" method="post">
Username: <input type="text" name="username">
Password: <input type="password" name="password">
<input type="submit" value="Login">
</form>
I need to retrieve the 'username' parameter in 'ChangePasswordServlet' as well.
Please help me with the format. I have tried searching for it but did not find any solution.
Add a second button for changing the password:
<input type="submit" value="Change Password" formaction="ChangePasswordServlet">

How to use state.setError with :records in CMFFormController

I'm using cmfformcontroller in an app to manage a list of entries.
Entries are displayed using :records as documented at http://pypi.python.org/pypi/zope.httpform
<form action=".">
<p>Please, enter information about one or more of your next of
kin.</p>
<p>
First Name <input type="text" name="people.fname:records" />
Last Name <input type="text" name="people.lname:records" />
</p>
<p>
First Name <input type="text" name="people.fname:records" />
Last Name <input type="text" name="people.lname:records" />
</p>
<p>
First Name <input type="text" name="people.fname:records" />
Last Name <input type="text" name="people.lname:records" />
</p>
<input type="submit" />
</form>
I want my validator to be able to highlight a record using state.setError method. How could I achieve this ?
I have fix this use case by keeping a list of error key pattern: on starting by a pattern: id_field

Resources