|
Your new hosting providers are idiots. Take your business elsewhere.
Just because the linked support article doesn't explicitly mention IIS10, that doesn't mean it "does not apply"; it means it applies to everything from IIS 6.0 (Windows Server 2003 SP2) onwards. Unsurprisingly, Microsoft don't go back and update every article written for one version of Windows every time a new version of Windows is released, just to add "still applies to Windows x.x".
CAS has been deprecated since 2009 / .NET Framework 4.0:
Enabling CAS Policy Compatibility Mode for a Project - .NET Blog[^]
Code Access Security (CAS) has been deprecated across all versions of .NET Framework and .NET. Recent versions of .NET do not honor CAS annotations and produce errors if CAS-related APIs are used. Developers should seek alternative means of accomplishing security tasks.
The fact that your new hosting company are still using "security" techniques that have been deprecated for at least 15 years should have you extremely worried!
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I built a simple 1 page site with Visual Studio 2022 using asp.net. It has a few buttons that display some images and 2 links to a subdomain. No additional modules were used... just published with straight VS.
The host I am using has the CAS trust level default as FULL and it works successfully if I leave it that way.
Now I want to change hosts and the new host does not support a FULL CAS Trust Level, only HIGH.
This is my web.config:
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
https:
-->
<configuration>
<appSettings>
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
<system.web>
<customErrors mode="Off" />
<compilation targetFramework="4.8" tempDirectory="D:\InetPub\vhosts\permitlvonline.com\tmp" />
<httpRuntime targetFramework="4.8" />
<securityPolicy>
<trustLevel name="Full" policyFile="internal" />
<trustLevel name="High" policyFile="web_hightrust.config" />
<trustLevel name="Medium" policyFile="web_mediumtrust.config" />
<trustLevel name="Low" policyFile="web_lowtrust.config" />
<trustLevel name="Minimal" policyFile="web_minimaltrust.config" />
</securityPolicy>
<trust level="High" />
</system.web>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" />
<bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" />
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-5.2.7.0" newVersion="5.2.7.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<system.codedom>
</system.codedom>
</configuration>
<!--ProjectGuid: 341B6D57-1384-4224-8AC6-C7F85BF0A4E3-->
I placed the web_hightrust.config file in the same folder as web.config.
This is the error message generated when I set CAS trust level to High. (instead of Full)
[SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0
System.Security.CodeAccessPermission.Demand() +57
System.Web.HttpContext.System.IServiceProvider.GetService(Type service) +79
System.Web.WebPages.UrlRewriterHelper.IsUrlRewriterTurnedOn(HttpContextBase httpContext) +128
System.Web.WebPages.UrlRewriterHelper.WasRequestRewritten(HttpContextBase httpContext) +16
System.Web.WebPages.UrlUtil.GenerateClientUrlInternal(HttpContextBase httpContext, String contentPath) +167
System.Web.WebPages.UrlUtil.GenerateClientUrlInternal(HttpContextBase httpContext, String contentPath) +113
System.Web.WebPages.UrlUtil.GenerateClientUrl(HttpContextBase httpContext, String basePath, String path, Object[] pathParts) +150
ASP._Page_Views_Shared__Layout_cshtml.Execute() +620
System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +252
System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +148
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +122
System.Web.WebPages.<>c__DisplayClass40_0.<RenderPageCore>b__0(TextWriter writer) +309
System.Web.WebPages.HelperResult.WriteTo(TextWriter writer) +18
System.Web.WebPages.WebPageBase.Write(HelperResult result) +108
System.Web.WebPages.WebPageBase.RenderSurrounding(String partialViewName, Action`1 body) +89
System.Web.WebPages.WebPageBase.PopContext() +310
System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +152
System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +378
System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +17
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +91
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +795
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +81
System.Web.Mvc.Async.<>c__DisplayClass3_6.<BeginInvokeAction>b__4() +262
System.Web.Mvc.Async.<>c__DisplayClass3_1.<BeginInvokeAction>b__1(IAsyncResult asyncResult) +188
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +60
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +38
System.Web.Mvc.<>c.<BeginExecuteCore>b__152_1(IAsyncResult asyncResult, ExecuteCoreState innerState) +29
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +73
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +60
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +52
System.Web.Mvc.<>c.<BeginExecute>b__151_2(IAsyncResult asyncResult, Controller controller) +17
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +39
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +60
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +38
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +14
System.Web.Mvc.<>c.<BeginProcessRequest>b__20_1(IAsyncResult asyncResult, ProcessRequestState innerState) +43
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +73
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +60
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +38
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +13
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +431
System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +75
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +158
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4718.0
I asked my current host for tech assistance and they did not have an answer but suggested I comment code out of the <system.codedom> section. There is no code to comment out so it's obvious they did not even look at my web.config file.
What do I need to change either in web.config or VS to get it change to a CAS level of HIGH?
|
|
|
|
|
ASP.NET MVC 5 does not support running in anything other than full trust. Microsoft have provided guidance for hosters to move away from using CAS trust levels and use proper OS-level isolation instead:
ASP.NET Partial Trust does not guarantee application isolation - Microsoft Support[^]
For .NET Core / .NET 5+ applications, CAS has been completely removed.
If your host doesn't understand that, or won't adopt the recommendations, then all you can do is take your business elsewhere.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
modified 4-Jul-24 4:05am.
|
|
|
|
|
Thank you for your reply. I forwarded it to my host tech support.
|
|
|
|
|
Hi Sir,
I'm already develop asp.net web application using Visual Studio 2019, when i want to publish the wep app on IIS, all the icon / image on my page not appear. Also no all folder that i create such as Images folder , Logs Folder not included in publish folder.
Can anyone help me? Really appreciate. Thanks
|
|
|
|
|
Based on such a vague problem description? No, nobody can help you.
You need to perform some basic diagnostics. Check how the images are referenced in the page; look at the source of the page in your browser to make sure the paths are correct; check the browser's network tab to see what response you get for the images; etc.
Nobody here has access to your system, so nobody can do that for you.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Is every file in your Images folder tagged as "Content"?
Click on the file in Visual Studio, then look in the Properties window below Solution Explorer. The Build Action for each file should say Content. If it doesn't, change it.
|
|
|
|
|
I have created a test ASP.NET Core MVC application in VS 2022.
I configured individual authentication so it automatically created a database in the (localdb)\MSSQLLocalDB database server for all authentication chores.
I need to deploy the test application to a web server along with its database.
Where in the application do I point it to the web server's database server? The appsettings.json file doesn't contain a connection string for the (localdb), so I don't know if that's the right place for a different connection string.
If you could point me in the right direction, I'll be grateful.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
The connection string is normally stored in the web.config file. If you haven't yet, try searching the entire solution for 'localdb'.
Jack of all trades, master of none, though often times better than master of one.
|
|
|
|
|
Thanks Ron. I found the place where the default connection string is defined. Problem solved.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
How do C programming principles influence C# .NET development, and how can understanding C help in mastering C#? Discuss the similarities in syntax, differences in memory management, the role of pointers, object-oriented programming concepts, platform independence, and use case differences. Share your experiences and insights on transitioning from C to C#.
|
|
|
|
|
Don't post the same thing all over the site. Once is enough. Any more than that, and you're going to get eyed as a spammer and treated as such.
|
|
|
|
|
how to fix "assertion failed : unrecognized tag script" error
Anant Patil
Broadllyne Technology
|
|
|
|
|
Probably by correcting the code that causes it. But unless you show us the actual code there is not much that can be suggested. Please edit your question and add complete details of the problem.
|
|
|
|
|
The error typically occurs when there is an issue with unrecognized tags within your application. This could happen if you are using a tag that is not recognized or if there's a syntax error in your markup. Show some code so we can understand the error rather than trying to read minds on where the issue is occurring.
|
|
|
|
|
I want to build my own gallery module and add it into Umbraco CMS.
is it difficult to do this?
diligent hands rule....
|
|
|
|
|
|
I am planning the development of ASP.NET Core MVC Razor application and am looking for FREE library of some quality that supports MVC/Razor development. I see plenty of commercial libraries like Kendo UI that can be used, but I am looking for something like Open Source Material Design. As far as I know, Material UI is usable only from SPA/React, and I want to develop MVC/Razor application that is Round-trip (Request/Response), not an SPA application like React.
|
|
|
|
|
Hello
Please note that I am sorry to take anyone's time out of whatever busy life they might have. So I have a professional class project which unfortunatly is related to coding even though its just about the first and last time this is supposed to happen. I am supposed to write a .net code in VS for windows VM that will show ip address of the VM from a browser. I am not a programmer nor any career close to that so I am completely stuck and dont want to just call it a day without trying every possible avenue on the internet. I have been on this for 24hrs trying on my own with different online forums even chatgpt/Bard but to no avail so I need help. Just help write the code to help a brother out please. I saw that VS has a bunch of asp.net templates so I kept shoveling between asp.net core web api and asp.net web app (razor pages) but no luck. This project is in aws and its part of the requirement I need to complete the project.
Am gratefull
modified 25-Nov-23 0:11am.
|
|
|
|
|
Sorry, but this site does not provide code to order. You need to go back to your teacher and explain why this task is beyond your capabilities.
|
|
|
|
|
Maybe view the question below this one, Richard has added very valuable links that will point you in the right direction - Starting in ASP.NET[^]
|
|
|
|
|
appache05 wrote: I am supposed to write a .net code in VS for windows VM that will show ip address of the VM from a browser
Just noting that if one has no programming experience then this is a very difficult project to start with.
So something odd is going on. For example you skipped a pre-requisite class. Or the teacher doesn't know what they are doing. Or perhaps you only needed to select a project from a multiple selection and you selected one that did not fit your skill set.
appache05 wrote: though its just about the first and last time this is supposed to happen.
...or perhaps you are mistaken about that in terms of what the class is doing in general.
|
|
|
|
|
I am a consultant, not a developer, so I mainly develop small customizations to my company's software as opposed to coding entire applications from scratch and selling them.
I have basic experience with HTML, though admittedly I've never personally written HTML code that has a div tag. I'm somewhat familiar with XML style sheets but it's been awhile. I remember that classic ASP code basically just dynamically produced HTML and sent it from the server to the client - I'm honestly not sure whether or not ASP.Net does the same thing. I'm somewhat familiar with JavaScript and VBScript and somewhat understand the difference between client-side code and server-side code. I've heard that there's this thing called Ajax - all I really know about it is that it makes it easier to write client-side code that actually interacts with the server. I've heard that my company's website uses the React framework but I don't know what that is. Regardless, ASP.Net web parts can be coded and then "pasted into" custom areas on the company's website. There are very rare needs to code entire ASPX web pages, but the ASCX controls are used a LOT.
I need to get to the point where I can code reasonably complex and dynamic ASP.Net web parts to paste into the main website. There are frequent business needs for which the right technical solution is either client-side code, server-side code or both. In most cases, the user interface is fairly simple, but I've seen some get fairly complex, i.e. the entire form can change based on a selection in a dropdown (i.e. a dropdown could include 4 or 5 different reports they can generate, and the input into each report could be totally different). I've also seen web parts that actually have a dynamic number of dropdowns on them (how that could POSSIBLY be the most efficient user interface for a given business need is beyond me, but I've seen it happen.
So here's the question - based on what little I know, what should I start studying/reading/practicing to get to where I can reach my goal? Any suggested online training sites and/or books I could buy to start learning?
Hope I elucidated the question sufficiently for it to be actionable.
Thanks
DalTXColtsFan
|
|
|
|
|
|
I wish it was a little easier to post screenshots here, but what's going on is my SelectedIndexChanged event handler is being triggered if I choose any item in the dropdown OTHER THAN THE TOP ONE. When I choose the top item in the dropdown, Page_Load is getting fired, but not SelectedIndexChanged. What's going on?
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="First2023WebUserControl.ascx.cs" Inherits="First2023Control.UserControls.First2023WebUserControl" %>
<asp:Label ID="Label1" runat="server" Text="Hello Year 2023"></asp:Label>
<p>
</p>
Category:<asp:DropDownList ID="ddlCategory" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlCategory_SelectedIndexChanged">
</asp:DropDownList>
<p>
Subcategory:
<asp:DropDownList ID="ddlSubcategory" runat="server" AutoPostBack="True">
</asp:DropDownList>
</p>
<p>
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
</p>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
<asp:Label ID="Label3" runat="server" Text="Label"></asp:Label>
protected void Page_Load(object sender, EventArgs e)
{
Label3.Text = "In Page Load selected index is " + ddlCategory.SelectedIndex.ToString();
XXXDbSupport objDBSupport = new XXXDbSupport();
DbCommand objDBCommand = objDBSupport.CreateDbCommand();
objDBCommand.CommandType = CommandType.Text;
string sSQL = "select distinct isnull(Category,'(blank)') as ProdCat from xxx_product order by isnull(Category,'(blank)')";
objDBCommand.CommandText = sSQL;
DataTable objDBTable = objDBSupport.FillDataTable(objDBCommand);
if (objDBTable.Rows.Count > 0)
{
ddlCategory.DataTextField = "ProdCat";
ddlCategory.DataValueField = "ProdCat";
ddlCategory.DataSource = objDBTable;
ddlCategory.DataBind();
}
else
{
ddlCategory.Text = "n/a";
}
}
protected void ddlCategory_SelectedIndexChanged(object sender, EventArgs e)
{
Label2.Text = "The selected index changed to " + ddlCategory.SelectedIndex.ToString();
XXXDbSupport objDBSupport = new XXXDbSupport();
DbCommand objDBCommand = objDBSupport.CreateDbCommand();
objDBCommand.CommandType = CommandType.Text;
string sSQL = "select distinct isnull(SubCategory,'(blank)') as SubCat from xxx_product ";
if (ddlCategory.Text == "(blank)")
{
sSQL = sSQL + "where isnull(Category,'(blank)') = '(blank)' order by isnull(SubCategory,'(blank)')";
}
else
{
sSQL = sSQL + "where Category = '" + ddlCategory.Text + "' order by isnull(SubCategory,'(blank)')";
}
objDBCommand.CommandText = sSQL;
DataTable objDBTable = objDBSupport.FillDataTable(objDBCommand);
if (objDBTable.Rows.Count > 0)
{
ddlSubcategory.DataTextField = "SubCat";
ddlSubcategory.DataValueField = "SubCat";
ddlSubcategory.DataSource = objDBTable;
ddlSubcategory.DataBind();
}
else
{
ddlSubcategory.Text = "n/a";
}
}
|
|
|
|