|
In Angular, the home page is set in App.Routes.ts.
{ path: "", redirectTo: "home", pathMatch: "full" },
So any wild card path that doesn't match another route gets sent to website.com/home, and the home.routes.ts takes it from there. Or if you type https://website.com/legal, the legal.routes.ts calculates the route.
{ path: "", component: HomeComponent },
{ path: "legal", loadChildren: "./legal/legal.module#LegalModule" },
{ path: "", redirectTo: "", pathMatch: "full" }
This allows typing https://website.com to load the home page https://website.com/home
Or allows sending a link to a page to share such as https://website.com/software/Angular
I suspect your thinking old school, like setting up IIS and setting the programs root folder to start from.
SPA in Setup.cs just tells SPA where the ng build root is, and calls the npmScript "start" in package.json. What SPA services really does is compiles or builds angular when you start the project.
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"build:ssr": "ng run jkirkerx:server:dev",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"postInstall": "npm rebuild node-sass"
},
The controller say .Net Core V2.2+ if that is what your using for back end logic has it's own routes that you assign to a controller. So this is the Store Controller, and is called by an Angular service as
https://website.com/api/Store/GetBrands/1/8
[Produces("application/json")]
[Route("api/[controller]")]
[ApiController]
public class StoreController : ControllerBase {
[HttpGet("GetBrands/{page}/{show}")]
public async Task<GetBrands> GetBrands(int page, int show)
{
return await _brandsRepository.GetBrands(page, show);<br />
}
}
With CORS setup correctly, only the client can call this Url, and if typed in the browser, Angular will reject the request and your Startup.cs will direct the request to the https://website.com/Error
if (env.EnvironmentName.Equals("Development"))
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Error");
app.UseWhen(context => !context.Request.Path.Value.StartsWith("/api"), builder =>
{
builder.UseStatusCodePagesWithReExecute("/Error/{0}");
});
app.UseHsts();
app.UseHttpsRedirection();
}
I've only done a Angular app wrapped in .Net Core V2.2+, and the two seem to bounce off each other in terms of Web hosting and protection if you program the Kestrel Web Server in Program.cs and Startup.cs. I could separate the 2 projects from each other and still formulate a solution that works in a Docker Container.
But like I said in the past, designing and building the hosting environment, testing it and fully understanding it is a huge project in itself with very little documentation on how to do it. I learned the hard way on how to program Kestrel, and then do it in a Docker Container. Something I will write a paper on here soon if anyone is interested in it.
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
|
I am creating a usercontrol named InvalidCaseUserControl in web forms for a web app. When I run the code in debug mode I am getting the following errors CS0079 The event 'Control.Disposed' can only appear on the left hand side of += or -=
Error CS7036 There is no argument given that corresponds to the required formal parameter 'e' of 'EventHandler'
Error CS0115 'InvalidCaseUserControl.Dispose(bool)': no suitable method found to override
How do I solve this?
public partial class InvalidCaseUserControl : System.Web.UI.UserControl
{
private int _batchNumber;
private System.ComponentModel.IContainer components = null;
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Disposed(disposing);
}
}
modified 3-Feb-20 13:46pm.
|
|
|
|
|
The base class doesn't have a method called Dispose which takes any parameters. Perhaps you meant to override the Control.Dispose method[^] instead?
public override void Dispose()
{
try
{
if (components != null)
{
components.Dispose();
}
}
finally
{
base.Dispose();
}
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thank you for your help. For now this seems to work. I will do more testing as I continue to add to the code.
|
|
|
|
|
Hello: We're hoping somebody here can help point us in the right direction for a web based project we're working on.
Based on user-input, we need to generate a diagram using real world units and render the output to the browser. e.g. the user enters width and height in inches, and we create a rectangle with these units. We've been trying to use SVG, but we're having trouble getting it to scale appropriately.
Appreciate any input you have to offer.
Thanks.
|
|
|
|
|
SVG seems perfect for that. The scale which is displayed on a monitor or which would be printed on a paper depends on the resolution (dpi) of the medium. Usually, for a monitor, it is 96 dpi; for printed documents it could be 300 or 600 dpi, or even more.
I would try to persevere with SVG and try to understand the mechanism which would bring rendered drawing to the appropriate scale.
"Five fruits and vegetables a day? What a joke!
Personally, after the third watermelon, I'm full."
|
|
|
|
|
Thank you for your reply. It helps to know I'm off in the right direction.
Would it be possible to look at my code to see if you can detect any reason why the SVG isn't scaling to fit inside a div. See the rectangle below:
<div style="width: 600px; height: 500px;">
<svg width="60in" height="15in" viewBox="0 0 60 15" style="border: 1px solid black;">
<line x1="30" y1="0" x2="30" y2="15" style="stroke:rgb(0,0,0);stroke-width:2px" vector-effect="non-scaling-stroke" />
</svg>
</div>
I appreciate your help
|
|
|
|
|
Maybe this will enlighten you:
How to Scale SVG | CSS-Tricks[^]
"Five fruits and vegetables a day? What a joke!
Personally, after the third watermelon, I'm full."
|
|
|
|
|
Has anyone used Swagger codegen and done customisation on auto generated .net project files
Manoj
|
|
|
|
|
I have an ASP .NET application that requires Document Mode to default to IE11. I have set the computer local IE11 browser to default to document mode IE11. The problem I have is when I deploy my ASP .NET site to IIS and browse to the site the Document Mode gets changes back to IE7 Default. Because of this my JavaScript does not work. How do I set the IE11 Document mode to IE11 default when I browse to the site and not change it back to IE7 default?
|
|
|
|
|
|
I have turned off the "Display intranet sites compatibility view" so when I open the browser without browsing it remains on IE11 as default. It's only when I browse my website does it change.
|
|
|
|
|
|
I don't see a 'compatibility view' button across the address bar.
|
|
|
|
|
I have added a database to my application and then published it in IIS. I am getting an SQL error and IIS error when trying to browse to the site and have been trying to figure it out all day. I hope you can look and see if you can come up with something. The IIS error is: "Cannot open database "KML" requested by the login. The login failed. Login failed for user 'NT AUTHORITY\SYSTEM'". The SQL error is: "[SqlException (0x80131904): Cannot open database 'KML' requested by the login. The login failed. Login failed for user 'NT_AUTHORITY\SYSTEM'. ] . I hope someone can figure out what the problem is. Thanks.
|
|
|
|
|
|
I am getting an error when I try to get case information from a database (Justice)
Here is the error:
{StatusCode: 500, ReasonPhrase: 'Internal Server Error', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{Pragma: no-cache Cache-Control: no-cache Date: Wed, 29 Jan 2020 22:07:12 GMT Server: Microsoft-IIS/8.0 X-AspNet-Version: 4.0.30319 X-Powered-By: ASP.NET Content-Length: 6066 Content-Type: application/json; charset=utf-8 Expires: -1 }}
I need help to solve the error StatusCode: 500 When button is clicked JusticeContoller class is called. This is where I am getting an error on line response=await client.GetAsync("api/GetAllAcceptCAseNumbers/" + candidateCases);
protected async void GetCasesButton_Click(object sender, EventArgs e)
{
if (CaseNumbersTextBox.Text.Length < 1)
{
string myStringVariable = "Case number textbox cannot be empty.";
ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + myStringVariable + "');", true);
return;
}
try
{
#region Get Batch Number
int newBatchNumber = await CandidateCaseController.GetNextBatchNumber();
#endregion
#region Insert entered case numbers in database
foreach (string caseNumber in userEnteredCaseNumberList)
{
EditCandidateCaseModel newCandidate = new EditCandidateCaseModel();
newCandidate.CaseNbr = caseNumber;
newCandidate.EntryStaffUserName = Helpers.Authentication.GetADEmail();
await CandidateCaseController.PostCandidate(newCandidate);
}
#region Get MNCIS info on cases
List<string> smallEnoughStrings = new List<string>();
List<AcceptCaseNumbersModel> mncisDetailList = new List<AcceptCaseNumbersModel>();
List<AcceptCaseNumbersModel> smallEnoughMncisDetailList = new List<AcceptCaseNumbersModel>();
foreach (string smallEnoughString in smallEnoughStrings)
{
smallEnoughMncisDetailList = await FTACaseReseting.Controllers.JusticeController.GetAllAcceptCaseNumbers(smallEnoughString);
mncisDetailList.AddRange(smallEnoughMncisDetailList);
}
#endregion
}
catch (Exception ex)
{
string errorMsg = string.Format("An error has occured in {0}. \nException:\n{1}", "GetCasesButton_Click()", ex.Message);
ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + errorMsg + "');", true);
}
}
Here is the class called when button click even happens
public class JusticeController
{
#region Get
public static async Task<List<AcceptCaseNumbersModel>> GetAllAcceptCaseNumbers(string candidateCases)
{
List<AcceptCaseNumbersModel> retVal = new List<AcceptCaseNumbersModel>();
TokenModel tm = new TokenModel();
tm = await TokenController.GetAccessToken();
if (tm.access_token.Length > 0)
{
using (HttpClient client = DataAccess.EstablishConnection(ConfigurationManager.AppSettings.Get("ServiceUri"), ConfigurationManager.AppSettings.Get("ServiceReturnType")))
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tm.access_token);
HttpResponseMessage response = new HttpResponseMessage();
response = await client.GetAsync("api/GetAllAcceptCaseNumbers/" + candidateCases);
if (response.IsSuccessStatusCode)
retVal = await response.Content.ReadAsAsync<List<AcceptCaseNumbersModel>>();
}
}
return retVal;
}
#endregion
}
|
|
|
|
|
An internal server error just means something has gone wrong in the server-side code. You'll need the actual error details to work out what the problem is.
Assuming the error is coming from the GetAllAcceptCaseNumbers method, the problem is with the service you're calling, not the code you've shown. You'll need to contact the developer(s) responsible for that service to fix the problem.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thank you for your response. You are exactly right. I did talk to someone and I need to get username and password the app need to use to connect to the server.
|
|
|
|
|
Hi I am getting the following error when I changed the path of the application - from source control, source control took the latest version of the application but started giving me the following error - any help please? This is the error messages that I am getting
Detailed Error Information:
Module WindowsAuthenticationModule
Notification AuthenticateRequest
Handler ExtensionlessUrlHandler-Integrated-4.0
Error Code 0x80070021
Config Error This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault="Deny"), or set explicitly by a location tag with overrideMode="Deny" or the legacy allowOverride="false".
Config File \\?\C:\SrcCode\IMS\Development\IMS\IMS.Web\web.config
Config Source:
99: <anonymousAuthentication enabled="true" />
100: <windowsAuthentication enabled="true" />
101: </authentication>
More Information:
This error occurs when there is a problem reading the configuration file for the Web server or Web application. In some cases, the event logs may contain more information about what caused this error.
If you see the text "There is a duplicate 'system.web.extensions/scripting/scriptResourceHandler' section defined", this error is because you are running a .NET Framework 3.5-based application in .NET Framework 4. If you are running WebMatrix, to resolve this problem, go to the Settings node to set the .NET Framework version to ".NET 2". You can also remove the extra sections from the web.config file.
View more information »
Any help please - its urgent - thanks in advance please
|
|
|
|
|
By default, sites are not allowed to change the Windows authentication settings.
You need to use IIS Manager to unlock that feature:
Delegating Features in IIS Manager | Microsoft Docs[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I resolved this issue changed the following
from
<section name="windowsAuthentication" overrideModeDefault="Deny" />
<section name="anonymousAuthentication" overrideModeDefault="Deny" />
<add name="AnonymousAuthenticationModule" lockItem="true" />
<add name="WindowsAuthenticationModule" lockItem="true" />
to
<section name="windowsAuthentication" overrideModeDefault="Allow" />
<section name="anonymousAuthentication" overrideModeDefault="Allow" />
<add name="AnonymousAuthenticationModule" lockItem="false" />
<add name="WindowsAuthenticationModule" lockItem="false" />
in the applicationhost.config file under the solution folder
|
|
|
|
|
Hello experts,
We have an app that prompts employees to enter his/her empID.
Once the employee enters his/her ID, the VB/Stored Proc checks the ID to determine if user has entered his/her information from previous year.
If no, the user gets a blank page to enter his/her data.
If user had entered data the previous year, our objective is to have data populate the GridView control giving the user the opportunity to review data and make changes if necessary.
The code largely works when populating data outside of GridView.
However, GridView is not getting populated with the two sourcename and spousename.
Obviously, it is not recognizing textboxes from GridView.
Any ideas how to resolve this?
My abbreviated code below. Thanks a lot in advnce
Sorry for the long code.
Stored Proc
ALTER PROCEDURE [dbo].[ValidateEmpID]
@empID varchar(50)
AS
BEGIN
SET NOCOUNT OFF;
SELECT employeeName, email, emptitle, EmpID,
CASE WHEN YEAR(d.dateCreated) = YEAR(getdate()) -1 THEN 1 ELSE 0 END as previousYear,
CASE WHEN YEAR(d.dateCreated) = YEAR(getdate()) THEN 1 ELSE 0 END as thisYear
FROM Employees e
INNER JOIN dateDetails d on e.employeeID = d.EmployeeID
INNER JOIN SourceDetails so on e.employeeID = so.EmployeeID
INNER JOIN SpouseDetails sp on e.employeeID = sp.employeeID
WHERE EmpID=@empID
END
<div class="table-responsive">
<table class="table">
<tr>
<td>
<div class="form-group">
<label for="lblEname"><span style="font-weight:bold;font-size:16px;color:#000000;">Employee Name</span><span style="color:#ff0000">*</span></label>
<asp:TextBox ID="txteName" placeholder="Employee name..." style="width:200px;" class="form-control" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator id="RequiredFieldValidator2" Font-Bold="true"
SetFocusOnError="true" runat="server"
ErrorMessage="*" ControlToValidate="txteName" /><br />
</div>
</td>
<td>
<div class="form-group">
<label id="lblTitle"><span style="font-weight:bold;font-size:16px;color:#000000;">Your title</span><span style="color:#ff0000">*</span></label>
<asp:TextBox ID="txttitle" placeholder="Employee title..." style="width:200px;" class="form-control" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator id="RequiredFieldValidator3" Font-Bold="true"
SetFocusOnError="true" runat="server"
ErrorMessage="*" ControlToValidate="txttitle" />
</div>
</td>
<td>
<div class="form-group">
<label id="lblEmail"><span style="font-weight:bold;font-size:16px;color:#000000;">Your email address</span><span style="color:#ff0000">*</span></label>
<asp:TextBox ID="txtemail" placeholder="Employee email..." style="width:200px;" class="form-control" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator id="RequiredFieldValidator4" Font-Bold="true"
SetFocusOnError="true" runat="server"
ErrorMessage="*" ControlToValidate="txtemail" />
</div>
</td>
</tr>
</table>
</div>
<table class="table">
<tr>
<td>
<asp:gridview ID="Gridview1" RowStyle-Wrap="false" gridlines="None" CssClass="responsiveTable1" runat="server" ShowFooter="true" AutoGenerateColumns="false" onrowdatabound="Gridview1_RowDataBound" OnRowDeleting="Gridview1_RowDeleting">
<Columns>
<asp:BoundField DataField="RowNumber" Visible="false" HeaderText="Row Number" />
<asp:TemplateField HeaderText="Name">
<headerstyle horizontalalign="Left" />
<ItemTemplate>
<asp:TextBox ID="txtsourcename" Text='<%# Eval("sourcename") %>' placeholder="Name...(e.g, Jane Doe)" runat="server" style="width:375px;" AutoPostBack="true" class="form-control textClass" OnTextChanged="txtsourcename_TextChanged"></asp:TextBox><br />
<asp:CheckBox ID="grid1Details" ClientIDMode="Static" runat="server" Checked="false" AutoPostBack="true" OnCheckedChanged="Grid1CheckChanged" /><span style="color:#ff0000">*Check this box if N/A</span>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Address">
<ItemStyle HorizontalAlign="Left"></ItemStyle>
<ItemTemplate>
<asp:TextBox ID="txtsourceaddress" Text='<%# Eval("sourceaddress") %>' placeholder="Address..." runat="server" style="width:375px;" class="form-control textClass"></asp:TextBox><br /><br />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="">
<ItemTemplate>
<asp:Button ID="ButtonAdd" runat="server" Text="Add another row if needed"
onclick="ButtonAdd_Click" CssClass="grvAddButton" /><br /><br /><br>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="">
<ItemTemplate>
<asp:Button ID="sourceDelete" runat="server" Text="Delete" CommandName="Delete"
CssClass="grvDelButton" OnClientClick="return confirm('Are you sure you want to remove this row?')" /> <br /><br /><br />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:gridview>
</td>
</tr>
</table>
Protected Sub txtEmpID_TextChanged(sender As Object, e As EventArgs) Handles txtEmpID.TextChanged
If Not String.IsNullOrEmpty(txtEmpID.Text) Then
Dim Conn As SqlConnection
'Read in connection String
Conn = New SqlConnection(ConfigurationManager.ConnectionStrings("constr").ConnectionString)
Conn.Open()
Dim cmd As New SqlCommand("ValidateEmpID", Conn)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.AddWithValue("@empID", txtEmpID.Text)
Dim dr As SqlDataReader = cmd.ExecuteReader()
If dr.HasRows Then
'Employee exists'
dr.Read()
checkusername.Visible = True
dprocessed.Visible = True
If dr("previousYear").ToString() = "1" Then
imgstatus.ImageUrl = "images/NotAvailable.jpg"
lblStatus.Text = "Please verify your information for accuracy. Then complete rest of the form."
lblStatus.ForeColor = System.Drawing.Color.Red
System.Threading.Thread.Sleep(300)
txteName.Text = dr("employeeName").ToString()
txttitle.Text = dr("empTitle").ToString()
txtemail.Text = dr("email").ToString()
txtEmpID.Text = dr("empID").ToString()
Dim currentRow As GridViewRow = CType((CType(sender, TextBox)).Parent.Parent.Parent.Parent, GridViewRow)
Dim txtsource As TextBox = CType(currentRow.FindControl("txtsourcename"), TextBox)
txtsource.Text = dr("sourcename").ToString()
Dim txtsource As TextBox = CType(currentRow.FindControl("txtspousename"), TextBox)
txtspouse.Text = dr("spousename").ToString()
ElseIf dr("thisYear").ToString() = "1" Then
imgstatus.ImageUrl = "images/NotAvailable.jpg"
lblStatus.Text = "You have already completed this Disclosure form. Please close the form. If you feel there is a mistake, please contact Clerk at xxx-xxx-xxxx"
lblStatus.ForeColor = System.Drawing.Color.Red
System.Threading.Thread.Sleep(300)
txteName.Text = dr("employeeName").ToString()
txttitle.Text = dr("empTitle").ToString()
txtemail.Text = dr("email").ToString()
txtEmpID.Text = dr("empID").ToString()
txteName.Enabled = False
txttitle.Enabled = False
txtemail.Enabled = False
txtEmpID.Enabled = False
GridPanels.Enabled = False
dprocessed.Visible = True
btnNext.Enabled = False
Else
'not this year, nor the previous year'
End If
Else
checkusername.Visible = True
dprocessed.Visible = True
imgstatus.ImageUrl = "images/Icon_Available.gif"
lblStatus.Text = "Proceed to complete entire form"
lblStatus.ForeColor = System.Drawing.Color.Red
System.Threading.Thread.Sleep(300)
txteName.Text = ""
txttitle.Text = ""
txtemail.Text = ""
End If
Else
checkusername.Visible = False
End If
End Sub
modified 30-Jan-20 14:12pm.
|
|
|
|
|
I can't see anything in that code which would bind data to the GridView. There's no DataSourceID or SelectMethod on the GridView, and nothing in the code that sets the DataSource .
There's also no sign of the txtEmpID control, and the CType((CType(sender, TextBox)).Parent.Parent.Parent.Parent, GridViewRow) looks suspicious to me.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|