|
Thanks for your suggestion I will keep it in mind and make sure I do it as soon as I am able to move to Windows 10. Currently, I do not have much choice except to stick around with Windows 8 whose tools are no longer supported.
As an update, I looked at the error message closer and noticed I am running Microsoft .NET Framework Version 4.7.02053 on Microsoft Visual Studio 2017, using SDK 2.2.207 (from the Microsoft download site Download .NET Core 2.2), and therein I think lies the problem.
I can't believe it skipped my eyes that SDK 2.2.207 has Visual Studio support for Visual Studio 2019 so obviously the SDK I should have installed was SDK 2.2.110 as it is the one carrying Visual Studio support for Visual Studio 2017 not SDK 2.2.207 so it's my bad.
Can I uninstall SDK 2.2.207 and restart and then install SDK 2.2.110 without any problem?
|
|
|
|
|
Hi Good Day,
I have been trying to redirect my http web pages using the rewrite module.
The module works in converting http link to https, but then the converted url path is not as expected.
For example:
original link: http://servername/folder/page_x.aspx
Converted link: https://servername/page_x.aspx
To achieve expected result, updated the rules in web.config file with various combinations of constructing the target url but i have had no luck.
Any tips/direction towards the fix will be really helpful.
|
|
|
|
|
This rule works fine for me:
<system.webServer>
<rewrite>
<rules>
<rule name="RequiresSSL-Redirect" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect" redirectType="Temporary" url="https://{HTTP_HOST}{REQUEST_URI}" appendQueryString="false" />
</rule>
</rules>
</rewrite>
</system.webServer>
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I have a model as follows:
[Key]
public int pmId { get; set; }
[Required]
public int pmNumber { get; set; }
[Required]
[MaxLength(50)]
public string costCenter { get; set; }
[Required]
[MaxLength(15)]
public string serviceType { get; set; }
[Required]
[MaxLength(50)]
public string destination { get; set; }
[Required]
[MaxLength(50)]
public string workCenter { get; set; }
[Required]
public DateTime creationDate { get; set; }
[Display]
[Required]
public DateTime startDate { get; set; }
[Required]
public DateTime endDate { get; set; }
[Required]
[MaxLength(100)]
public string mainFileName { get; set; }
public DateTime? returnDate { get; set; }
public string? status { get; set; }
[MaxLength(100)]
public string? fileName { get; set; }
public int? uploader { get; set; }
public bool? isDownloaded { get; set; } = false;
public virtual AppUser user { get; set; }
public PM()
{
}
The Foreign Key is id which is Primary Key of the EF Core Identity table. In a form, I need to insert a new row in PM table. I can fill all necessary columns using the following code:
var inputElements = new PM()
{
pmNumber = Convert.ToInt32(adminModel.pmNumber),
costCenter = adminModel.costCenter,
serviceType = adminModel.serviceType,
destination = adminModel.destination,
workCenter = adminModel.workCenter,
creationDate = DateTime.Now,
startDate = DateTime.Now,
endDate = DateTime.Now,
mainFileName = newFileName
};
But, because of relational nature of my tables, I need to specify userId when creating a new row in PM table. How can I set Foreign Key? I can detect userId using Session object but I don't know how to insert it in the table.
modified 19-Dec-21 13:22pm.
|
|
|
|
|
I added the following code to PM model:
public int userId { get; set; }
and changed the navigation property to the following code:
[ForeignKey("userId ")]
public virtual AppUser user { get; set; }
|
|
|
|
|
|
How would we possibly know where you got something?
If you want help, you need to ask better questions.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I think the question deserves an upvote for the depth of thought that went into that question!
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
I want to have two ReportViewer controls in my VS project. I have two completely different types of reports and I want to split them between two RepportViewers that would be processed in two ReportViewer.aspx.cs. I have create copies of three files:
ReportViewer1.aspx
ReportViewer1.aspx.cs
ReportViewer1.aspx.designer.cs
in ReportViewer1.aspx.designer.cs I changed this line:
protected global::Microsoft.Reporting.WebForms.ReportViewer ReportViewer2;
In ReportViewer1.aspx.cs I name dthe class like this:
public partial class ReportViewer1
Inside of this class I changed all ReportViewer1 to ReportViewer2.
I also modified ReportViewer1.aspx.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ReportViewer1.aspx.cs" Inherits="PrismWeb.reports.ReportViewer1" EnableEventValidation="false" %>
rsweb:ReportViewer1 ID="ReportViewer2" runat="server" Height="100%" Width="100%">
Call from UI:
/reports/ReportViewer1.aspx crashes somewhere on the server, cannot fine where.
However, if I call /reports/ReportViewer.aspx with same changes I did in ReportViewer1.aspx then it works fine. I just can't figure out why calling ReportViewer1.asx is not working.
Please note, I am not a c# developer, I might be doing something abviously wrong. Please help.
Thanks
|
|
|
|
|
Quote: crashes somewhere on the server What are the symptoms of that "crash" - any errors reported?
|
|
|
|
|
I use the following code for dependency injection of Register/Login controller. The problem is that I cannot use Repository pattern I have created previously.
private readonly UserManager<AppUser> _userManager;
private readonly SignInManager<AppUser> _signInManager;
private readonly IUserRepository _userRepository;
public HomeController(UserManager<AppUser> userManager, SignInManager<AppUser> signInManager, IUserRepository userRepository)
{
_userManager = userManager;
_signInManager = signInManager;
_userRepository = userRepository;
}
When I run the code, the following error is occured:
Quote: InvalidOperationException: Unable to resolve service for type 'CustomizedIdentity.Repositories.IUserRepository' while attempting to activate 'CustomizedIdentity.Controllers.HomeController'.
modified 6-Dec-21 14:00pm.
|
|
|
|
|
You haven't registered an implementation of your IUserRepository service in your DI container. You need to fix your service registration code to register that service, and any services it depends on.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|
I am trying to create a site on IIS that can allow users to manually thru their mobile phones (yes they will have access to this internal site), and use their AD username/password to login. Anyone that's valid is allowed in. Once authenticated will present the next page. Plus that next page wouldn't allow them on it unless they are authenticated. Does anyone have any sample ASP.NET Web examples to get me started? Don't usually develop applications within IIS other than HTML pages so looking for any samples to get me started. Having a hard time finding one that isn't how to use Azure online.
|
|
|
|
|
Hi,
I'm creating models for my ASP.NET Core project. I want to use "Code First" approach to create database and tables. Please check these annotations to be correct:
[Required]
[DataType(DataType.Date)]
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:MM/dd/yyyy}")]
public DateTime creationDate { get; set; }
[Required]
[DataType(DataType.Time)]
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:HH:mm:ss}")]
public DateTime creationTime { get; set; }
And please tell me that what 0 means inside the curly braces.
|
|
|
|
|
The DataFormatString value is a format string to convert a date to a string in the format shown. The zero gives the position of the data parameter (following the format string) when the format is used, like:
string theDate = string.Format(DataFormatString, someDateTimeValue);
See String.Format Method (System) | Microsoft Docs[^]
|
|
|
|
|
Is data annotation for the time correct?
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:HH:mm:ss}")]
|
|
|
|
|
I deliberately did not answer that part because I don't know the answer. Does it correspond to the documentation?
|
|
|
|
|
No, I did not find any reference for time format. Can I use String type instead?
|
|
|
|
|
|
I get what you want to do here, which is to create models to match your database perhaps, so each table has a matching model. But your over thinking this, and don't need that much detail. Keep it simple and flexible at first, and only add detail when needed. For some reason Microsoft likes to capitalize the first letter, and will nag you later about the first letter being lower case.
This is an example model in c# to match a DB table or collection. Your example is a like a model used to present data in the view. Even when presenting data in the view, I would keep that simple as well. You want to craft models as simple as possible, and try to make them as reusable as possible to keep models down in count.
public class PORTFOLIOS
{
public string Id { get; set; }
public DateTime TimeStamp { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public string CreatedBy { get; set; }
public string UpdatedBy { get; set; }
public DateTime UpdateDate { get; set; }
public string HTML { get; set; }
public string AvatarB64 { get; set; }
public string AvatarName { get; set; }
public string AvatarType { get; set; }
public string AvatarUrl { get; set; }
public int AvatarX { get; set; }
public int AvatarY { get; set; }
}
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
Hi,
I'm using ASP.NET Core 6. I'm trying to establish a local connection with SQL SERVER. The authentication method is Windows Auth. I used the following code in appsettings.json:
"ConnectionStrings": {
"AuthConnectionString": "Server=.;Database=AspNetAuth;Trusted_Connection=True"
}
And following code in program.cs:
builder.Services.AddDbContext<AuthDbContex>(options => options.UseSqlServer(builder.Configuration.GetConnectionString("AuthConnectionString")));
builder.Services.AddIdentity<IdentityUser, IdentityRole>().AddEntityFrameworkStores<AuthDbContex>();
I created Migration, but when I try to update database, the following error is occured:
Quote: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
|
|
|
|
|
Are you sure that . is a valid server address?
|
|
|
|
|
In a SQL connection string, . resolves to the local computer.
You can even use it with a named instance - for example: server=.\SQLEXPRESS
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks, not seen it used before.
|
|
|
|