I have registered below javascript in my view of mvc3 application.
jquery.validate.js
jquery.validate.unobtrusive.js
I have also added below keys to my web.config.
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
I have also added required attribute with error message above the text box but when I submit the form with blank value in text box "input-validation-error" class will not added to that text box.
Please tell me the reason why "input-validation-error" class will not added while submit the form.???
Thanks in advance.
Jayesh Ginoya
Related
I have already configured unobtrusive and jquery-val to validate client-side, when I click on submit button the validate verify the fields and return the propers messages from the model, after that the aplication hint the controller action ignoring the jquery-val and submit the form.
So, the validation works but still submitting.
I have already checked the correctly scripts:
<script src="/Scripts/jquery-2.1.1.js"></script>
<script src="/Scripts/jquery.unobtrusive-ajax.js"></script>
<script src="/Scripts/jquery.validate.js"></script>
<script src="/Scripts/jquery.validate.unobtrusive.js"></script>
And the configuration on web.config:
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
Also my model there are the proper validation notation and in my view I use
#Html.ValidationSummary(true)
What I'm doing wrong?
thanks!
I have a .NET MVC application that uses Azure Active Directory for Auth.
I'm trying to add a custom JWTSecurityTokenHandler to authenticate a console app that performs some basic GET requests against the app. However every request just gets redirected to the Azure AD login page instead of being passed to the JWT handler (my breakpoints and logging statements in the handler are not being hit). Any ideas?
Web.config:
<system.identityModel>
<identityConfiguration>
<audienceUris>
<add value="https://localhost:44300/" />
</audienceUris>
<securityTokenHandlers>
<add type="QS.Admin.Infrastructure.MyJwtHandler, QS.Admin" />
<securityTokenHandlerConfiguration>
<certificateValidation certificateValidationMode="None" />
</securityTokenHandlerConfiguration>
</securityTokenHandlers>
<issuerNameRegistry type="System.IdentityModel.Tokens.ValidatingIssuerNameRegistry, System.IdentityModel.Tokens.ValidatingIssuerNameRegistry">
<authority name="https://[myaccessdomain].accesscontrol.windows.net/">
<keys>
<add thumbprint="[thumbprint]" />
</keys>
<validIssuers>
<add name="https://[myaccessdomain].accesscontrol.windows.net/" />
</validIssuers>
</authority>
</issuerNameRegistry>
<!--certificationValidationMode set to "None" by the the Identity and Access Tool for Visual Studio. For development purposes.-->
<certificateValidation certificateValidationMode="None" />
</identityConfiguration>
</system.identityModel>
<system.identityModel.services>
<federationConfiguration>
<cookieHandler requireSsl="false" />
<wsFederation passiveRedirectEnabled="true" issuer="https://[myaccessdomain].accesscontrol.windows.net/v2/wsfederation" realm="https://localhost:44300/" requireHttps="false" />
</federationConfiguration>
</system.identityModel.services>
in addition to the above advice,
the jwtsecuritytokenhandlers responsibility is to validate a jwt and serve claims upstream. I don't see session management anywhere in your config, if that is missing, each call to the host will require obtaining a new token from ACS.
The settings in web.config look right.
Couple of things to check :
Make sure ACS is configured to issue JWT tokens for your realm.
If you plug in the JwtSecurityTokenHandler from MS - is it getting hit? This will help in isolating the issue to your custom handler versus settings in ACS or web.config.
I've got 2 projects: Core and Web.
Core project has API controllers, models, etc. Web project has html pages only.
I'm loading data from API using jQuery. When I do this exactly from Core project (created a view), everything is ok. But when I do this from Web project, I've got error 404, but Fiddler shows everything is ok.
Why is it so? What's a problem?
I found the answer. That is because it's cross domain application. And it's necessary to implement CORS support. It can be done by two ways.
First. Add to section of web.config file next:
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Headers" value="Content-Type" />
<add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE, OPTIONS" />
</customHeaders>
</httpProtocol>
Second. Create custom MessageHandler. Like in this post
I have some custom Html helpers for my Asp.net MVC 3 app. In the main application they work correctly as I have put the following in my Web.Config:
<pages clientIDMode="AutoID">
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages"/>
<add namespace="WebDibaelsaMVC.Utils.HtmlHelpers" />
<add namespace="WebDibaelsaMVC.Utils.HtmlHelpers.DTOs" />
</namespaces>
</pages>
but I have now created an area and to make my custom helpers work I have to add a using in every page where I use them. Is there a way to add the default namespaces for that area?
If you are using Razor you might need to add the reference to the <namespaces> section in the ~/Views/web.config and ~/Areas/YourAreaName/Views/web.config and not the main ~/web.config file. Also make sure you recompile the project, open close the view, maybe even restart Visual Studio for changes to take effect (in terms of Intellisense, it will work if you run the project).
I'm new to ASP.NET MVC and don't understand the purpose of all the JavaScript files that are added to the project by default.
What's the purpose of MicrosoftMvcValidation.js? Whatever it's used for, can it be swapped out for a jquery-based implementation? If so, how?
MicrosoftMvcValidation.js will be used if you decide that you do not want to use the new unobtrusive jQuery validation on the client side.
You can make this choice for you entire applicastion in the web.config file here:
<appSettings>
<add key="ClientValidationEnabled" value="true"/>
<add key="UnobtrusiveJavaScriptEnabled" value="true"/>
</appSettings>
So in the above example the jQuery validation will be used.