it is quite handy, if we can extract data from our C# object list and send them to your teammate for debugging purpose.
Here is the tool that provide the great need
https://marketplace.visualstudio.com/items?itemName=OmarElabd.ObjectExporter
it is compatible for Visual Studio 2013,2015,2017
You just have to highlight the data list object that you plan to export the data.
First, you go to Tools--> Object Explorer
Second Pick the object from the List
third pick either Json,XML data format to export the data.
a blog to share Microsoft technologies Azure, DotNet, SharePoint, SQL Server,JavaScript Framework: Node.JS, Angular, React
Monday, November 13, 2017
Wednesday, November 8, 2017
how to control the page access in the controller level in MVC web application?
we can control the page access in various area in the MVC web applicaton.
first we can control in the razor page file.
@if (!this.User.HasPermission(ADGroup))
{
Response.Redirect("~/ErrorMessage.aspx?ErrorCode=AccessDenied");
}
second we can control access in the Action method.
public async Task<ActionResult> MyPage()
{
if (!IsAllowAccess)
{
return Redirect("~/ErrorMessage.aspx?ErrorCode=AccessDenied");
}
}
third we can set the access permission in the Class level by implmented an ActionFilterAttribute.
public class MyPageAccessActionFilterAttribute : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
if (!IsAllowAccessPage)
{
filterContext.Result = new RedirectResult("~/ErrorMessage.aspx?ErrorCode=AccessDenied");
}
base.OnActionExecuting(filterContext);
}
}
Then in Page Controller, I can just set the MyPageAccessActionFilter Attribute in controller class
[MyPageAccessActionFilter]
public class MyController : Controller
{
}
the third approach will reduce lots of code and affect on the maintenance. since we can easily modify one file to apply permission on the action methods within the controller.
first we can control in the razor page file.
@if (!this.User.HasPermission(ADGroup))
{
Response.Redirect("~/ErrorMessage.aspx?ErrorCode=AccessDenied");
}
second we can control access in the Action method.
public async Task<ActionResult> MyPage()
{
if (!IsAllowAccess)
{
return Redirect("~/ErrorMessage.aspx?ErrorCode=AccessDenied");
}
}
third we can set the access permission in the Class level by implmented an ActionFilterAttribute.
public class MyPageAccessActionFilterAttribute : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
if (!IsAllowAccessPage)
{
filterContext.Result = new RedirectResult("~/ErrorMessage.aspx?ErrorCode=AccessDenied");
}
base.OnActionExecuting(filterContext);
}
}
Then in Page Controller, I can just set the MyPageAccessActionFilter Attribute in controller class
[MyPageAccessActionFilter]
public class MyController : Controller
{
}
the third approach will reduce lots of code and affect on the maintenance. since we can easily modify one file to apply permission on the action methods within the controller.
Tuesday, November 7, 2017
How to download a document Web Application accessed from UAG
we can easy to use javascript Window.Open to download a document in IE or popup it up in Chrome and Firefox.
However, the user access the web application from UAG, then error indicates that the document is not found with the url absolute path. since the UAG had block the actual host server of the web application and shown the user with the UAG host server.
it is quick simply to work around it. we should return the relative path to front end for the Window.Open method.
Before:
Window.Open("Http://myserver/myapp/filefolder/myDoc")
After
Window.Open("myapp/filefolder/myDoc")
In the Server, we can use the following snippet code to demonstrate this approach.
if (baseUrl.Contains("localhost"))
{
response.fileName = baseUrl + "/Downloads/" + response.fileName ;
}
else
{
string currentAppFolder = System.AppDomain.CurrentDomain.BaseDirectory;
if (!string.IsNullOrEmpty(currentAppFolder))
{
string parentFolder = string.Empty;
currentAppFolder = currentAppFolder.Trim('\\');
int index = currentAppFolder.LastIndexOf("\\");
if (index > -1) {
parentFolder = currentAppFolder.Substring(index);
}
response.nvisFileName = parentFolder + "/Downloads/" + response.fileName ;
}
}
However, the user access the web application from UAG, then error indicates that the document is not found with the url absolute path. since the UAG had block the actual host server of the web application and shown the user with the UAG host server.
it is quick simply to work around it. we should return the relative path to front end for the Window.Open method.
Before:
Window.Open("Http://myserver/myapp/filefolder/myDoc")
After
Window.Open("myapp/filefolder/myDoc")
In the Server, we can use the following snippet code to demonstrate this approach.
if (baseUrl.Contains("localhost"))
{
response.fileName = baseUrl + "/Downloads/" + response.fileName ;
}
else
{
string currentAppFolder = System.AppDomain.CurrentDomain.BaseDirectory;
if (!string.IsNullOrEmpty(currentAppFolder))
{
string parentFolder = string.Empty;
currentAppFolder = currentAppFolder.Trim('\\');
int index = currentAppFolder.LastIndexOf("\\");
if (index > -1) {
parentFolder = currentAppFolder.Substring(index);
}
response.nvisFileName = parentFolder + "/Downloads/" + response.fileName ;
}
}
Thursday, October 19, 2017
how to debug a SharePoint Provider Hosted Add-in in Visual Studio 2017
I did not have to make any configuration when i developed my SharePoint Add-In with Visual Studio 2013.
However i was unable to debug my SharePoint Provider Hosted Add-In in Visual Studio 2017.
I had to make quick change in the project property from Visual Studio
1. Select the SharePoint Add-In Project, then press F4 to launch the Property Window
2. change from Google Chrome to Internet Explorer from Start Action drop down
3. Press F5 to launch the project in debugging mode.
4. Select Attached to Process from the Debug Menu to enable Visual Studio to debug the IIS process
5. click on the show process for all users if your app is running with Service Account App Pool
6. Selected w3wp.exe process and click Attach button
now you can debug you web app within SharePoint Provider Hosted Add-In solution.
However i was unable to debug my SharePoint Provider Hosted Add-In in Visual Studio 2017.
I had to make quick change in the project property from Visual Studio
1. Select the SharePoint Add-In Project, then press F4 to launch the Property Window
2. change from Google Chrome to Internet Explorer from Start Action drop down
3. Press F5 to launch the project in debugging mode.
4. Select Attached to Process from the Debug Menu to enable Visual Studio to debug the IIS process
5. click on the show process for all users if your app is running with Service Account App Pool
6. Selected w3wp.exe process and click Attach button
now you can debug you web app within SharePoint Provider Hosted Add-In solution.
Subscribe to:
Posts (Atom)