Access to path denied - IIS express - upload file -Windows 8.1 - c#

I know this error maybe very popular and there are many people asking about it. I have read through other threads but can not seem to find a solution applicable to my scenario.
I am new to ASP.NET programming, am using vs 2013 ultimate, IIS express on my laptop with Windows 8.1.
I have created a new website using WebForms and I was testing the upload function to my local machine running IIS express that came with VS2013.
My code behind is as simple as
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class MyWebForm : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
string name = TextBox1.Text;
string type = DropDownList1.SelectedValue;
string filename = FileUpload1.FileName;
FileUpload1.SaveAs(Server.MapPath("~/Content"));
}
}
}
Ran it and got this error:
{"Access to the path 'C:\\Users\\xxx\\Documents\\Visual Studio 2013\\WebSites\\WebFormDemo\\Content' is denied."}
I understand that it is an unauthorized access due to lack of privilege, but my question is how do I give access to my application? I have admin right on my machine, run it locally so the firewall should not be an issue. Some threads suggested to go to IIS manager and adjust the right to DefaultPool but I do not think I have InetMgr on my Windows 8.1,
How do I solve the unauthorized access for my case?

Related

'Access is Denied' IIS on killing a windows process

I have created a Web API for installing the latest version of exe using Web API and hosted via IIS Server.
The process is Downloading -> Closing -> Installing Exe via CLI.
The downloading process is working fine.
While closing the running exe exception caught "Access is denied."
Following is the code block I am using to close the running exe.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using WebGrease;
namespace API.Controllers
{
public class TestController : ApiController
{
public string Get()
{
foreach (Process p in Process.GetProcessesByName("APPLICATION NAME"))
{
try
{
p.Kill();
p.WaitForExit();
}
catch (Exception ex)
{
return ex.Message.ToString();
}
}
return "Aborted";
}
}
}
While debugging the same this code block is working fine but when testing on another computer it says "Access is Denied".I guess this issue is related to Windows Authentication.
Debugging the above code will take the current logged window account as the credential to run the WebAPI. However, some other built-in system account will be used when the project is hosted in the IIS. This is commonly determined by the IIS application pool identity.
Although granting the administrative permission to IIS is risky for website security, at least this could solve your problem.
Feel free to let me know if the problem still exists.

Can't launch chrome driver in Selenium

I was always able to launch chromedriver server locally but then I tried to do this remotely and since then I am unable to launch it. I reinstalled chrome as well the chrome driver but nothing seems to fix this. Even when I give the path of my driver it won't launch.
using OpenQA.Selenium;
using OpenQA.Selenium.Support;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.IE;
using OpenQA.Selenium.Chrome;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenQA.Selenium.Safari;
using OpenQA.Selenium.Interactions;
namespace TestWebDriver
{
class Program
{
static void Main(string[] args)
{
var driver = new ChromeDriver(#"C:\Users\laurens.putseys\Documents\Visual Studio 2015\Projects\TestWebDriver\packages\Selenium.WebDriver.ChromeDriver.2.21.0.0\driver\");
driver.Url = "http://google.be";
Console.ReadLine();
driver.Quit();
}
}
}
The error I get is the following:
An unhandled exception of type 'System.InvalidOperationException' occurred in WebDriver.dll
Additional information: unknown error: chrome failed to start
(Driver info: chromedriver=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=Windows NT 6.1 SP1 x86_64)
It started after I tried this:
System.Environment.SetEnvironmentVariable("webdriver.chrome.driver",#"/path/to/where/you/ve/put/chromedriver.exe"
Now I cannot launch the local either. Launching IE and Firefox local work without any problems. Any ideas? Thanks in advance!
try downloading the driver and give its path to contractor - LINK
driver = new ChromeDriver(DRIVER_PATH);
By the version number (2.21.371459) you can tell that the ChromeDriver executable has been launched by your remote Selenium server. But the ChromeDriver was obviously unable to launch the Chrome browser. Is it installed on the server? Can you launch is manually? Can you watch the remote server on a screen and see what happens? Are there any error message boxes displayed by Chrome?
Maybe uninstalling and re-installing Chrome could help!
I had the same problem. I had the browser set to always run under the administrator.
So I started Visual Studio as an administrator and the problem was solved.

cannot find the SPSite name space

I am unable to find the name space for the SPSite
I have imported these so far:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using Microsoft.SharePoint;
using System.Collections;
using Microsoft.SharePoint.Client;
using Microsoft.SharePoint;
using System.Data.SqlClient;
using SP = Microsoft.SharePoint.Client;
using System.Data;
namespace GrandPermission
{
class Program
{
static void Main(string[] args)
{
SPSite oSPSite = new SPSite("http://spdevserver:1002/");
}
}
}
And SPSite still has red line under it.
This error occurs since SPSite class is a part of Server Side Object Model API:
Server Side Object Model API could be utilized only on machine where SharePoint Server/Foundation is installed.
Since you are using Client Object Model API (referenced assembly in your project Microsoft.SharePoint.Client.dll is a part of SharePoint Server 2013 Client Components SDK) i would recommend to utilize this API.
So, the line:
SPSite oSPSite = new SPSite("http://spdevserver:1002/"); //SSOM
could be replaced with:
using(var ctx = new ClientContext("http://spdevserver:1002/"))
{
var site = ctx.Site;
//...
}
References
Choose the right API set in SharePoint 2013
Based on your screenshot, you are missing a reference to Microsoft.SharePoint in your project's references. You only have a reference to the client dll.
If you're not finding it, make sure you're either developing on a SharePoint server, i.e. SharePoint is installed, or have a copy of the dll on your machine. I've seen forum posts where someone copied the SharePoint dll from a SharePoint server to a local non-SharePoint development machine. However, I've never gotten that to work. I've always installed SharePoint on a development server and ran Visual Studio from it.
You need to add the assembly Microsoft.SharePoint.dll into your references in order to use it. You can find this DLL on the SharePoint server that you're working with:
On SharePoint 2013 it lives at:
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI
And on SharePoint 2010 it can be found at:
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI

Execute SSIS Package Using ASP.Net

Description Of Environment
I have an SSIS task which executes from asp.net, the package gets data from excel files over UNC path and puts the data into a sql server databaase . I have deployed the SSIS to file system, it has windows authentication database connections and the IIS user has database access. I can log in as the AppPoolUser I have used to host the web application and open/modify the files in question so those basic permissions are there. Web App is compiled in x86.
When it works:
When run from Visual Studio (ctrl + shift + W) it works fine and every thing is done succefuly.
When it doesn't work:
When run from client browser. it upload the file but fail in the package.
My Question
What is different about the client and server and how do I make it work? I was under the impression that when running the web app all connections go through the AppPool User so it should behave the same on any machine server included? i need to do so without the need of CMD.
c# Code running SSIS Package
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.SqlServer.Dts.Runtime;
public partial class Pages_Quality : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Upload_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
string fileExt =
System.IO.Path.GetExtension(FileUpload1.FileName);
if (FileUpload1.FileName == "Breached.xlsx")
{
try
{
FileUpload1.SaveAs("*:\\***\\***\\" +
FileUpload1.FileName);
Label1.Text = "Upload Done";
Application app = new Application();
Package package = app.LoadPackage(#"*:\**\**\Quality.dtsx", null);
DTSExecResult result = package.Execute();
Label2.Text = (result.ToString());
}
catch (Exception ex)
{
Label1.Text = "ERROR: " + ex.Message.ToString();
}
}
else
{
Label1.Text = "Only Breached.xls is allowed!";
}
}
else
{
Label1.Text = "You have not specified a file.";
}
}
}
Do you have SSIS service or SSIS Component (Client Tools) installed in the machine (web server in your case) where you are deploying and running your application from?
You may have bids in the same development PC where you have Visual Studio to develop and debug your application application. Usually the SSIS component is installed along with BIDs so you do not need SSIS service to run the package. This might be the case where your package execution is fine in you development PC. However it will never work in your web server because you do not have these components installed in your web server.
Hope this will help you.
Regards,
Sandip
If you are using Excel source connection, most probably the error happened because the excel driver work under 32 bit mode only, while when you try to call it from web, it's execute under 64 bit.
Check that.
Regards

How to run cosmos application

I have used following code (cosmos + Visual Studio 2008) but on pressing F5 application does not run, rather it provides an error: "microsoft visual studio has encountered an error and need to be close"
using System;
using System.Collections.Generic;
using System.Text;
namespace cosmos.user.kernel
{
public class program
{
public static void Init()
{
Cosmos.Sys.Boot xBoot = new Cosmos.Sys.Boot();
xBoot.Execute();
//Main();
}
static void Main()
{
// Boot the Cosmos kernel:
Cosmos.Compiler.Builder.BuildUI.Run();
//Cosmos.Sys.Boot xBoot = new Cosmos.Sys.Boot();
//xBoot.Execute();
Console.WriteLine("Cosmos booted successfully. Type a line of text to get it echoed back:");
string xResult = Console.ReadLine();
Console.Write("Text typed: ");
Console.WriteLine(xResult);
}
}
}
Since Cosmos is a different operating system, Visual Studio might have issues with trying to debug this thing.
I'd check what Cosmos FAQ and figure out what to do. Browsing the FAQ myself, I see the following disclaimer:
What version of Visual Studio can I
use to develop Cosmos?
Currently we
only support Visual Studio 2008. We
plan to support Visual Studio 2010 in
the future, but right now we have more
important features to complete.
Also, I notice in their Wiki that some folks have had a crashing bug with the VS 2008 integration.

Categories

Resources