|
Well I've made it this now, which is pretty good. I've almost completed the porting over the front end of my portfolio website and I'm working with the database now, in which I chose MongoDB since that seems to be the buzz word for job apps.
A couple I don't understand about MongoDB. Guess the first question is the auto increment for the index column. Guess Mongo uses a unique identifier based on some other logic, so I used ObjectId.GenerateNewId(); Below is an example of my controller code which writes to Mongo successfully. see the CRMMessage;
Q1: Should I just get rid of the "Id" which was int and is now string and just use InternalId? Or does MongoDB have the same mechanism that will auto increment?
So before I added the the respository to the controller function, it worked fine. Angular would register a success and run my success code. But now it returns something I can't see, which results in Error 500 according to Chrome F12.
Q2: Should I just change IActionResult to void and return nothing? I'm lost here on this.
[HttpPost]
public IActionResult AddMessage([FromBody] CRMMessage message)
{
if (message == null)
{
return BadRequest();
}
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
_crmRespository.AddMessage(new CRMMessage
{
InternalId = ObjectId.GenerateNewId(),
Name = message.Name,
CompanyName = message.CompanyName,
EmailAddress = message.EmailAddress,
PhoneNumber = message.PhoneNumber,
PhoneMobile = message.PhoneMobile,
TimeZone = message.TimeZone,
TimeStamp = message.TimeStamp,
UpdatedOn = message.TimeStamp,
Message = message.Message,
RememberMe = message.RememberMe
});
return CreatedAtRoute("GetSingleMessage", new { id = message.Id }, message);
}
This is my Angular 6, TypeScript onSubmit Function. I know this question is in the wrong section bought thought I'd ask anyways since it tied together. I wonder how it knows the difference between a success and an error. There are tools like postman in which I need to learn how to use.
onSubmit() {
this.dataService.addMessage(this.model).subscribe(
() => {
this.messageSuccess = true;
this.getStartedForm.reset();
this.model.name = '';
this.model.companyName = '';
this.model.emailAddress = ''
this.model.phoneNumber = '';
this.model.phoneMobile = '';
this.model.message = '';
setTimeout(() => {
this.messageSuccess = false;
this.getStartedModal.hide();
this.router.navigate(['/home/getStarted']);<br />
}, 3000);
},
error => {
console.log(error);
}
);
My Angular journey has been confusing because there are so many different examples and versions of Angular. I'm actually dual developing between a pure Angular 6 app in cli and this .Net Core 2.1 version so I can see the different between the two, determine which info is correct. Angular 6 using cli and ng on a text editor is more straight forward to learn first.
Any thoughts besides giving up would be appreciated.
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
Did some reading up on it and now it makes sense to me.
Changed the id to InternalId that was generated by MongoDB.Bson and called GetSingleMessage to confirm the write, which results in a 201 code.
This must be part of the CRUD operation procedure.
I'll read up on the Id part, auto-increment for MongoDB. Then figure out if I need it the value of not, and whether it should be a string or int.
Must admit it was exciting to see my angular app work correctly.
var result = CreatedAtRoute("GetSingleMessage", new { id = message.InternalId }, message);
return result;
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
Hi,
I am trying to use Elmah for my ASP.Net MVC application, in which I was somewhat successful, I could able to see errors like if I try to access url without action method like 404 etc.
But I have questions how Elmah works like
- If I have multiple layers like one Web Service and another one is UI layer, then is it better to include Elmah in both projects separately or just adding it on one Project UI is fine?
- Elmah to Work do I need to log the Errors into Elmah Database explicitly or is the Elmah going to catch the exceptions and write it in the Elmah Database, I have included the Connection string and details in the Web Config of both the Service and UI and included the DLLs as well in both the applications. Is it enough or do I need to write the Exceptions into the Elmah Db
- If I have multiple layers of application, one in that is UI layer and another one is Web Service Layer, then how would I know if any error happened in Data access layer within Web Serice or Business layer within Web Service, do I need to log it into Database of Elmah or how can I do that?
- Which is better way to log errors using Elmah, file or Database, I am using Database, it it ok?
- My most important Concern is how to secure my application? When I have Elma, it shows that we can directly access the errors, I want to make sure only the Developers should be able to access the Errors or Exceptions information, not even Admin users of the Application, can you please give me some suggestions.
I have these questions, can anybody please help me with these, thanks in advance.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
-- modified 13-Aug-18 12:18pm.
|
|
|
|
|
I am Creating my dashboard page to show line chart pie chart and bar chart in asp.net web form. I don't have any idea about that can you help me to develope the page or any links where i can get demo. Which js file i have to use for this. I don't have idea please suggest me or give me the sample code asap. Its client urgent requirement. help me please.
|
|
|
|
|
Use Google to find a charting library.
|
|
|
|
|
When i host WEB API on cloud and call from Another application then facing this issue
Server Error in '/' Application.
The remote name could not be resolved
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Net.WebException: The remote name could not be resolved:
-:Please help:-
|
|
|
|
|
As the error says, your code is trying to make a call to a remote server that doesn't exist.
We can't see your code, and we can't access your network, so we can't tell you how to fix it. You'll need to debug your code, and correct the name of the server that it's trying to call.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
It's likely a DNS issue. Make sure you have a good entry for your endpoint.
Easy check on windows cli:
nslookup my.domain.name
If you don't get an IP address result, the DNS is not setup properly.
"Never attribute to malice that which can be explained by stupidity."
- Hanlon's Razor
|
|
|
|
|
Hi all friends,
I have a textbox like below, I want call jquery function on its onblur or onkeyup or onfocus etc.
@Html.Kendo().TextBoxFor(model => model.Code).HtmlAttributes(new { autocomplete = "off", id = "idTxtForCodeLookupCode" })
when I set it as
$("#idTxtForCodeLookupCode").on('input', function ()
{
debugger;
SetLookupTableValue();
});
function SetLookupTableValue()
{
$("#txtLookupTableId").val($("#drpLookup").data("kendoDropDownList").value());
$("#txtLookupTableId").val();
}
The SetLookupTableValue() function is not being called. I don't know the reason, maybe because TextBox is in Popup and the functions are in the main page.
But I want to try it it works it I can set this onblur event or keyup or even onfocus events using HtmlAttributes, it might work.
Can anybody please help me how to set those events using HtmlAttributes property. Any help would be very helpful, thanks in advance.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
Depends on the version of JQuery your using. The call changes as versions are updated.
Technically, JQuery can select an element anywhere on the page or in the DOM, even if it's hidden.
Best thing to do is test first. just have the function write an alert to see if it works first, then write your code to do it's thing.
$("#idTxtForCodeLookupCode").on('blur', function ()
$("#idTxtForCodeLookupCode").blur(function() {
focus, blur, keyup is very tricky and requires more code to listen to certain keys.
I'm going to a seminar, the post JQuery world, in which basically JQuery is no longer needed with modern JavaScript and TypeScript being available now. Something for us to think about.
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
The meetup was pretty cool. Technically we don't need JQuery anymore for modern browsers that support HTML5, because modern JavaScript is now part of the browser. You save a 2 meg download on pages that use JQuery. There are many small npm libraries like animate.css that are around 64K in size that can do animation for you and Ajax is built in now.
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
Hi all,
I have overridden GetValidators method of CustomModelValidatorProvider in class CustomModelValidatorProvider, when a Post is happening, this Validator is getting all the values that I have input on the screen but I have Hidden field that I want to pass into this method is not coming in.
public class CustomModelValidatorProvider : System.Web.Mvc.DataAnnotationsModelValidatorProvider
{
protected override IEnumerable<System.Web.Mvc.ModelValidator> GetValidators(System.Web.Mvc.ModelMetadata metadata, ControllerContext context, IEnumerable<Attribute> attributes)
{
var z = metadata.PropertyName;
if ((metadata.PropertyName == "Code")
&& (metadata.ContainerType.FullName == "DHCS.BH.Provider.Models.LookupTable"))
{
LookupTable model = metadata.Container as LookupTable;
var newAttributes = new List<Attribute>(attributes);
var stringLength = newAttributes.OfType<StringLengthAttribute>().FirstOrDefault();
if (stringLength != null)
{
newAttributes.Remove(stringLength);
if (model.CodeLength != 0)
{
newAttributes.Add(new StringLengthAttribute(model.CodeLength)
{
MinimumLength = model.CodeLength,
ErrorMessage = @"The field {{0}} length must be at least {model.CodeLength}."
});
}
attributes = newAttributes;
}
}
return base.GetValidators(metadata, context, attributes);
}
public string GetPropertyName<T>(Expression<Func<T>> propertyLambda)
{
var me = propertyLambda.Body as MemberExpression;
if (me == null)
{
throw new ArgumentException("You must pass a lambda of the form: '() => Class.Property' or '() => object.Property'");
}
return me.Member.Name;
}
}
My cshtml file is as below, it is a Popup that's being generated for Create and Edit buttons of Kendo Grid.
@model DHCS.BH.Provider.Models.LookupTable
@{
ViewBag.Title = "EditLookup";
}
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<pre>
<div class="k-edit-form-container">
@*<div class="editor-field">
@Html.Kendo().TextBoxFor(model => model.LookupTableId).HtmlAttributes(new { autocomplete = "off", id = "idXYZ" })
</div>*@
@Html.HiddenFor(model => model.LookupTableId, new { id = "txtLookupTableId" })
<div class="editor-label">
@Html.LabelFor(model => model.Code)
</div>
<div class="editor-field">
@Html.Kendo().TextBoxFor(model => model.Code).HtmlAttributes(new { autocomplete = "off", id = "idTxtForCodeLookupCode" })<br />
<br />
<label id="lblCodeValidationMessage" style="color:gray;font-style:italic;font-size:smaller;font-weight:normal;">Testing</label>
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Description)
</div>
<div class="editor-field">
@Html.Kendo().TextBoxFor(model => model.Description).HtmlAttributes(new { autocomplete = "off", id = "idTxtForDescLookupCode" })
<label id="lblDescriptionValidationMessage" style="color:gray;font-style:italic;font-size:x-small;font-weight:normal;"></label><br />
</div>
<div class="editor-label" >
<label id="lblIsValid">Is Active: </label>
</div>
<div class="editor-field" style="padding-top: 10px;">
@Html.Kendo().CheckBoxFor(model => model.IsValid)
</div>
</div>
}
SetLookupTableValue();
And method SetLookupTableValue sets the value of the HiddenField txtLookupTableId, when I click on the save all other Textbox and Checkbox values coming in the model of the above GetValidators method but the LookupTableId value is coming as null, any help for this would very great help, thanks in advance.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
Are you sure that txtLookupTableId is being set correctly?
You can use a tool like Fiddler[^] to inspect the raw HTTP post to check the value coming in.
|
|
|
|
|
Yes I mean in the JavaScript function but I am not sure if something else is happening between the RequestEnd javascript function call and opening the Popup.
I want to write a text changed event for the Kendo Textbox, idTxtForCodeLookupCode, can you please help me how to write it using jquery, maybe if I assign value to the HiddenField: txtLookupTableId, it would be good.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
With this code:
@Html.HiddenFor(model => model.LookupTableId, new { id = "txtLookupTableId" })
You are setting the value of the hidden field to whatever is in your model's LookupTableId property. This is done on the server side when the view is rendered.
I don't know anything about Kendo components so I can't help you there. For a troubleshooting approach on the client side, try using the developer tools built in to the browser (F12 on chrome). You can set breakpoints and log to the console using console.log. This should help you see what is going on in your event handler.
Good luck!
|
|
|
|
|
I a new to web service project . I'm getting HTTP Error 403.14 - Forbidden whenever I debug my .asmx web service project . It says
HTTP Error 403.14 - Forbidden The Web server is configured to not list the contents of this directory.
to enable directory but it's not going to work . How to solve this error? Please Help? Any clue will be helpful .
EDIT
I added
<system.webserver>
<directorybrowse enabled="true">
this into web.config now I can see all the directory content but whenever I click .cs a page I get this error HTTP Error 404.7 - Not Found The request filtering module is configured to deny the file extension.
And
when I click the .asmx project I get the parser error
Server Error in '/' Application. Parser Error Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
I am debugging my project in local
|
|
|
|
|
sudipta saha wrote: Please review the following specific parse error details and modify your source file appropriately.
So what happened after you reviewed the specific parse error details and modified your source files?
If you want someone here to help you fix the errors in your code, then we need to see the relevant parts of your code, the full details of the errors.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi thank you for your reply Smile | . my project's url is localhost:3525 that's all . But my production site's url is http://abcdef.com/maidweb/ . whenever I'm trying to debug my project it gives me 403.14 error and says to enable directory . I wrote this enabled = true then I can see the content of directories but when I click into asmx project it says
Server Error in '/' Application. Parser Error Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Detailed Error
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Could not create type 'abcd.xyz.Services.Endpoints.BaseWebserver'.
Source Error:
Line 1: <%@ WebService Language="C#" CodeBehind="BaseWebService.asmx.cs" Class="abcd.xyz.Services.Endpoints.BaseWebserver" %>
Source File: /BaseWebService.asmx Line: 1
Version Information: Microsoft .NET Framework Version:2.0.50727.8789; ASP.NET Version:2.0.50727.8762
How to solve this error . How to see the output of asmx web service related projects in visual studio 2015 .
|
|
|
|
|
There is not enough information here but I suspect you are trying to access base URL. Are you accessing the asmx file in the URL?
"It is easy to decipher extraterrestrial signals after deciphering Javascript and VB6 themselves.", ISanti[ ^]
|
|
|
|
|
Hi thank you for your reply . my project's url is localhost:3525 that's all . But my production site's url is http://abcdef.com/maidweb/ . whenever I'm trying to debug my project it gives me 403.14 error and says to enable directory . I wrote this enabled = true then I can see the content of directories but when I click into asmx project it says
Server Error in '/' Application. Parser Error Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Detailed Error
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Could not create type 'abcd.xyz.Services.Endpoints.BaseWebserver'.
Source Error:
Line 1: <%@ WebService Language="C#" CodeBehind="BaseWebService.asmx.cs" Class="abcd.xyz.Services.Endpoints.BaseWebserver" %>
Source File: /BaseWebService.asmx Line: 1
Version Information: Microsoft .NET Framework Version:2.0.50727.8789; ASP.NET Version:2.0.50727.8762
How to solve this error . How to see the output of asmx web service related projects in visual studio 2015 .
|
|
|
|
|
Parser error could occur because your asmx file is not valid. The error would provide line number along with more details to sort out the problem.
"It is easy to decipher extraterrestrial signals after deciphering Javascript and VB6 themselves.", ISanti[ ^]
|
|
|
|
|
Hi,
Actually you are right class name wasn't correct at all . my file name was BaseService.asmx and I wrote BaseServer instead of writing BaseService . But htnl page isn't loading at all . Still some issue is there but finally it opened . Thanks
|
|
|
|
|
HttpPostedFileBase model property is not getting in click function in jquery ajax
|
|
|
|
|
Not really a good post now, is it? Give more details, show some relevant code and tell where the problem is. Also, share what you have tried so far so people do not recommend same thing again.
"It is easy to decipher extraterrestrial signals after deciphering Javascript and VB6 themselves.", ISanti[ ^]
|
|
|
|
|
$("#btnSubmit").click(function (event) {
$.ajax({
url: actionMethod,
type: "POST",
data: $("#myFormID").serialize(), //here the file type not get post(it is the issue)
cache: false,
datatype: "json",
processData: false,
success: function (result) {
//doing my task
}
})
return false;
}
if i use submit i can get file type value (HttpPostedFileBase) value but i was doing some client side validations so i need this in click event.
|
|
|
|
|