Wednesday, May 5, 2021

SharePoint Error: Access Denied. You do not have permission to perform this action or access this resource

 This error can occur at many places e.g. creating a workflow, accessing list items or user permissions using CSOM, or simply trying to navigate to the settings page. Its meaning is pretty straight forward. In dev server setup it can be resolved by providing full control permissions to the dev users.


  • Go to Central Administration
  • Go to Application Management
  • Go to Manage Web Application
  • Select the web application we’re talking about
  • Click User Policy
  • Add Users
  • Click Next
  • Fill in domain\superuser
  • Select Full Control
  • Click OK

For staging and production environments though, we should be careful to assing only the required permissions.


Reference: http://www.sharepointchick.com/archive/2010/10/06/resolving-the-super-user-account-utilized-by-the-cache-is.aspx

Thursday, April 1, 2021

WebApi 2 - CORS error after deployment Access to the path '/bin/roslyn/csc.exe' denied

 This error can be seen after redeployment of the API website in developer tools (F12) 

 

This is a misleading error message; real underlying problem is application pool account for the API website does not have execute permissions on the API website’s folder.  

The permissions problem can be seen by trying to open api website on the IIS Server hosting this website. If we try to send AJAX request to the API website on the hosting IIS server, the error message changes to 




[Win32Exception (0x80004005): Access is denied] 

 

[ExternalException (0x80004005): Cannot execute a program. The command being executed was "<path of the API website folder on server>/bin/csc.exe" /shared /keepalive:"10" /noconfig  /fullpaths @"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\5a229d66\a33ece8d\xf2kzry1.cmdline".]



 


This problem can be fixed by navigating to the IIS server and providing full control permissions for app pool account on the API Website folder.



If we don't want this issue to repeat after every deployment, we can add IncludeSetAclProviderOnDestination tag in the publish profile (.pubxml) file as explained at https://stackoverflow.com/questions/54911986/iis-application-pool-identity-permissions-reset-on-every-visual-studio-app-publi



<?xml version="1.0" encoding="UTF-8"?> <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0"> <PropertyGroup> <IncludeSetAclProviderOnDestination>False</IncludeSetAclProviderOnDestination> </PropertyGroup> </Project>

This parameter can also be added to .csproj file or as msbuild parameter as exlpained at https://blogs.iis.net/msdeploy/skipping-setting-an-acl-in-a-visual-studio-2010-deployment-package


1) Edit the .csproj file and set  <IncludeSetAclProviderOnDestination>False</IncludeSetAclProviderOnDestination>

2) msbuild.exe myproject.csproj /p:IncludeSetAclProviderOnDestination=False


Another way of specifying permissions is explained at https://davidsonsousa.net/blog/post/setting-folder-permissions-using-web-deploy


More references/options:



  1. https://docs.microsoft.com/en-us/answers/questions/202683/why-is-access-to-the-path-39binroslyn39-denied.html
  2. https://stackoverflow.com/questions/54893505/server-error-in-application-access-is-denied
  3. https://stackoverflow.com/questions/32780315/could-not-find-a-part-of-the-path-bin-roslyn-csc-exe


Wednesday, March 3, 2021

Partial views in bootstrap modal using AJAX

 This article explains how partial views can be used in bootstrap modal for CRUD operations on a related child entity. It uses ajax to dynamically load and save content displayed in a bootstrap modal dialog box.


https://www.codeproject.com/Articles/786085/ASP-NET-MVC-List-Editor-with-Bootstrap-Modals

Tuesday, February 16, 2021

Thursday, January 28, 2021

Regex Email validation in c# dot net core

 Use this regex /^_?[a-zA-Z0-9]([a-zA-Z0-9]*[._+-])*[a-zA-Z0-9_]+@(?!-)[A-Za-z0-9-]{1,63}(?<!-)(\.(?!-)[A-Za-z0-9-]{1,63}(?<!-))*\.[A-...