Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
ASP.NET : is there a way to use rdp in my web application?I need to create asp.net application and open remote desktop from my pc to another one though my web page
You can also check Myrtille, which is similar to Guacamole, but for Windows.
PS: Myrtille is the open source incarnation of Steemind cited above. I just saw the comment as I write these lines. #lopsided: please apologize my high latency reply.
Here, We have created new rdp file with dynamic IP address to mentioned path and the same will be downloaded by using HttpResponseMessage
API Controller
using System.Text;
using System.Web.Mvc;
namespace SafeIntranet.Controllers
{
public class RemoteDesktopController : Controller
{
public HttpResponseMessage GetRDPFileDownload(string ipAddress)
{
string filePath = #"C:\Test\AzureVMFile.rdp";
if (File.Exists(filePath))
{
File.Delete(filePath);
}
using (FileStream fs = File.Create(filePath))
{
Byte[] title = new UTF8Encoding(true).GetBytes("full address:s:" + ipAddress + ":3389 \nprompt for credentials:i:1 \nadministrative session:i:1");
fs.Write(title, 0, title.Length);
}
MemoryStream dataStream = null;
var fileBytes = File.ReadAllBytes(filePath);
dataStream = new MemoryStream(fileBytes);
HttpResponseMessage HttpResponseMessage = Request.CreateResponse(HttpStatusCode.OK);
HttpResponseMessage.Content = new StreamContent(dataStream);
HttpResponseMessage.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment");
HttpResponseMessage.Content.Headers.ContentDisposition.FileName = "AzureVM.rdp";
HttpResponseMessage.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/octet-stream");
return HttpResponseMessage;
}
}
}
Client Side Code:
window.location.href = "https:\\api.test.com\v1\azure\GetRDPFileDownload?ipAddress=10.10.10.10";
I don't believe there is any way you can launch RDP from asp.net and relay it through the browser, there are other remoting solution that are web based, you can check out:
GoTo My PC: http://www.gotomypc.com/
and
LogMeIn: http://www.logmein.com/
If you don't need a GUI but need your ASP.NET to execute remote code on the other server you can probably use PowerShell's remoting features:
http://technet.microsoft.com/en-us/library/dd819505.aspx
I do believe Window server already supports this you just need to install the RDP remote application watch this youtube to find out how to install http://www.youtube.com/watch?v=S6CIAGfcTU8&feature=related
info http://www.youtube.com/watch?v=7KKtTw5RTCc
Pass this code to an HTML File and if you want you can divide it later no an ASP.net aspx file separating the HTML and Code Behind.
http://msdn.microsoft.com/en-us/library/windows/desktop/aa380809%28v=vs.85%29.aspx
Check out the minimal requirements to client machine.
Good Programming ! fellow "blue color workers" of the digital world ! :)
You can create a link which will download an automatically generated .rdp file in ASP.Net MVC using a simple controller.
Create a controller:
using System.Text;
using System.Web.Mvc;
namespace SafeIntranet.Controllers
{
public class RemoteDesktopController : Controller
{
public ActionResult Index(string link)
{
Response.AddHeader("content-disposition", "attachment; filename= " + link + ".rdp");
return new FileContentResult(
Encoding.UTF8.GetBytes($"full address:s: {link}"),
"application/rdp");
}
}
}
Create a link to call this in you view:
#Html.ActionLink("RemoteMachineName", "Index", "RemoteDesktop", new { link = "RemoteMachineName" }, null)
Or:
RemoteMachineName
Related
I have run into a road block developing my Codename One app. One of my classes in my project parses 3 specific html "td" elements from a website and saves the text to a string where I then input that text data into a Codename One multibutton. I originally used jSoup for this operation but soon realized that Codename One doesn't support 3rd party jar files so I used this method as shown below.
public void showOilPrice() {
if (current != null) {
current.show();
return;
}
WebBrowser b = new WebBrowser() {
#Override
public void onLoad(String url) {
BrowserComponent c = (BrowserComponent) this.getInternal();
JavascriptContext ctx = new JavascriptContext(c);
String wtiLast = (String) ctx.get("document.getElementById('pair_8849').childNodes[4].innerText");
String wtiPrev = (String) ctx.get("document.getElementById('pair_8849').childNodes[5].innerText");
String wtiChange = (String) ctx.get("document.getElementById('pair_8849').childNodes[8].innerText");
Form op = new Form("Oil Prices", new BoxLayout(BoxLayout.Y_AXIS));
MultiButton wti = new MultiButton("West Texas Intermediate");
Image icon = null;
Image emblem = null;
wti.setEmblem(emblem);
wti.setTextLine2("Current Price: " + wtiLast);
wti.setTextLine3("Previous: " + wtiPrev);
wti.setTextLine4("Change: " + wtiChange);
op.add(wti);
op.show();
}
};
b.setURL("https://sslcomrates.forexprostools.com/index.php?force_lang=1&pairs_ids=8833;8849;954867;8988;8861;8862;&header-text-color=%23FFFFFF&curr-name-color=%230059b0&inner-text-color=%23000000&green-text-color=%232A8215&green-background=%23B7F4C2&red-text-color=%23DC0001&red-background=%23FFE2E2&inner-border-color=%23CBCBCB&border-color=%23cbcbcb&bg1=%23F6F6F6&bg2=%23ffffff&open=show&last_update=show");
}
This method works in the simulator (and gives a "depreciated API" warning), but does not run when I submit my build online after signing. I have imported the parse4cn1 and cn1JSON libraries and have gone through a series of obstacles but I still receive a build error when I submit. I want to start fresh and use an alternative method if one exists. Is there a way that I can rewrite this segment of code without having to use these libraries? Maybe by using the XMLParser class?
The deprecation is for the WebBrowser class. You can use BrowserComponent directly so WebBrowser is redundant in this case.
I used XMLParser for this use case in the past. It should work with HTML as it was originally designed to show HTML.
It might also be possible to port JSoup to Codename One although I'm not sure about the scope of effort involved.
It's very possible that onLoad isn't invoked for a site you don't actually see rendered so the question is what specifically failed on the device?
thanks to all for your time and efforts trying to help me solve this.
Now lets get to it... I have an AngularJS SPA. I would like to provide links on my view page, that when clicked, open a new tab and launch pre-existing SSRS reports in PDF format. Technically what I am trying to do: Render an SSRS report in my Repository, pass that through my WEB API then on to my SPA for display in a new tab.
One important note before I go any further: This setup, method, approach works flawlessly on my local machine within Visual Studio. It's when I move my SPA to a remote Web server (the same server that hosts SSRS) that I have a problem.
My Landscape:
Local Development Machine (Windows 7 Pro, VS2015 Pro)
Server1 (Win Server 2012R2): Hosts IIS (8), SPA, SQL (2014) and SSRS
Server2 (Win Server 2012R2). Hosts SSRS (SQL 2012) source of data (happens to be SSAS cubes, but I don't think that matters).
On My Local Development Machine:
As stated above the solution works fine through Visual Studio. The only part of the solution on my local machine is the SPA. The SSRS and SQL portion are located remotely. I can launch my SPA, click on a link and new tab opens containing the PDF report. I can also make a call directly to the web API and display a PDF report (http://localhost:3040/api/dataservice/ProductivityReportH/)
Problem 1
Browsing to the deployed version of my SPA on Server1, the application displays fine. But, if I click on a report hyperlink I get a the following message:
Do you want to open or save ProductivityReportH/ (3.28KB) from Server1?
No matter what I click (Open, Save, Cancel) nothing happens.
If I try and launch the report directly through the API, I get the same message. There are no errors displayed in the console window. I could find no errors in the Server1 log files.
On Server1: I can display the report via the SSRS report viewer.
Problem 1A
Using a browser on Server1, I can display the application just fine. But, if I click on a report hyperlink I get the same message as Problem 1. If I try to launch the report directly through the web API (http://Server1/projecttracker/api/dataservice/ProductivityReportH/)
on Server1, I get the same message.
Any ideas would be greatly appreciated
My SPA Setup:
View Page:
<div class="view indent">
<div class="container">
<h2>Productivity Reports Method 1</h2>
<a ng-href='#here' ng-click="hproductivityreport()">Launch</a><br>
</div>
My Controller:
(function () {
var ProjectsController = function ($scope, $window) {
$scope.hproductivityreport = function () {
$window.open('api/dataservice/ProductivityReportH/', '_blank');
};
}
ProjectsController.$inject = ['$scope', '$window'];
angular.module('ReportTracker').controller('ProjectsController', ProjectsController)
}());
The WEB API:
using ProjectTracker.Repository;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Web;
using System.Web.Http;
namespace ProjectTracker.Model
{
[Authorize]
public class DataServiceController : ApiController
{
IProjectTracker _ProjectTrackerRepository;
public DataServiceController()
: this(null)
{
}
public DataServiceController(IProjectTracker Repo)
{
_ProjectTrackerRepository = Repo ?? new ProjectTrackerRepository ();
}
[HttpGet]
public HttpResponseMessage ProductivityReportH()
{
var result = new HttpResponseMessage(HttpStatusCode.OK);
byte[] bytes = _ProjectTrackerRepository.RenderProductivityReport("Hibble, Norman");
Stream stream = new MemoryStream(bytes);
result.Content = new StreamContent(stream);
result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/pdf");
return result;
}
}
}
The Respository:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Data;
namespace ProjectTracker.Repository
{
public class ProjectTrackerRepository : RepositoryBase<ProjectTrackerContext>, IProjectTracker
{
ProjectTrackerContext _Context;
public ProjectTrackerRepository()
{
_Context = new ProjectTrackerContext();
}
public Byte[] RenderProductivityReport(string _sManager)
{
Server1.ReportExecutionService rs = new Server1.ReportExecutionService();
rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
rs.Url = "http://Server1/reportserver/ReportExecution2005.asmx";
// Render arguments
byte[] result = null;
string reportPath = "/Staff Client Services/StaffProductivity";
string format = "PDF";
string historyID = null;
string devInfo = #"<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>";
//Create the list of parameters that will be passed to the report
List<Server1.ParameterValue> lstParameterValues = new List<Server1.ParameterValue>();
Server1.ParameterValue aParameter = new Server1.ParameterValue();
aParameter.Name = "SupervisorSupervisorName";
aParameter.Value = "[Supervisor].[Supervisor Name].&[" + _sManager + "]";
lstParameterValues.Add(aParameter);
Server1.ParameterValue bParameter = new Server1.ParameterValue();
bParameter.Name = "PayPeriodPayPeriodYear";
bParameter.Value = "[Pay Period].[Pay Period Year].&[2015]";
lstParameterValues.Add(bParameter);
int index = 0;
Server1.ParameterValue[] parameterValues = new Server1.ParameterValue[lstParameterValues.Count];
foreach (Server1.ParameterValue parameterValue in lstParameterValues)
{
parameterValues[index] = parameterValue;
index++;
}
string encoding;
string mimeType;
string extension;
Server1.Warning[] warnings = null;
string[] streamIDs = null;
Server1.ExecutionInfo execInfo = new Server1.ExecutionInfo();
Server1.ExecutionHeader execHeader = new Server1.ExecutionHeader();
rs.ExecutionHeaderValue = execHeader;
execInfo = rs.LoadReport(reportPath, historyID);
rs.SetExecutionParameters(parameterValues, "en-us");
String SessionId = rs.ExecutionHeaderValue.ExecutionID;
try
{
result = rs.Render(format, devInfo, out extension, out encoding, out mimeType, out warnings, out streamIDs);
execInfo = rs.GetExecutionInfo();
}
catch (Exception e)
{
Exception Errr = e.InnerException;
}
return result;
}
}
}
Finally! For those that are interested...
Found this from nearly two years ago.
AppPool Permission Issue with Accessing Report Server
In particular the comment below:
Almost the same situation here except IIS and Report Server running on Windows Server 2008 R2. I used to have the asp.net application running with it's own application pool and everything worked. When I changed the application to the DefaultAppPool (due to a different problem), I got the permissions problem. I changed the Identity of the DefaultAppPool from ApplicationPoolIdentity to LocalSystem (in IIS, Advanced Settings) and it worked again.
Changed web server default app pool to LocalSystem and wha-la, I am rendering PDF reports from an SSAS cube through my AngularJS SPA.
I would like to know how best to handle file upload and addtional information added to the file to be uploaded using ASP.NET Web API 2 without MVC components. I have google the net and I can tell you I am more confused than I expected.
The Additional info will be stored in db and the file on the disk.
So far the Web API app I am building does not support multipart/form-data. It only supports the default media types. I know I need to create a media formatter.
Pls help.
I had wrote Javascript split File and upload to WEB API . i think you can reference my backend codes
In front-end you need using below code to upload your File
var xhr = new self.XMLHttpRequest();
xhr.open('POST', url, false);
xhr.setRequestHeader('Content-Type', 'application/octet-stream');
xhr.send(chunk);
In backend use Request.InputStream.Read to catch your file bytes
[HttpPost]
[ValidateInput(false)]
public string fileUpload(string filename)
{
byte[] file = new byte[Request.InputStream.Length];
Request.InputStream.Read(file, 0, Convert.ToInt32(Request.InputStream.Length));
BinaryWriter binWriter = new BinaryWriter(new MemoryStream());
binWriter.Write(file);
StreamReader reader = new StreamReader(binWriter.BaseStream);
reader.BaseStream.Position = 0;
//This example is recevied text file
while ((line = reader.ReadLine()) != null)
{
};
}
You can just serialize your file data into BASE64 and send them as a string in case of multipart/from-data is not allowed for some reason.
I am using the Youtube api for asp.net to rename a video:
public static void UpdateVideoInfo(string video_id, string new_title)
{
Uri entry = new Uri("http://gdata.youtube.com/feeds/api/videos/" + video_id);
Video video = AuthRequest().Retrieve<Video>(entry);
if (video.ReadOnly == false)
{
video.Title = new_title;
}
else video.Title = video.Title;
Video updatedvideo = AuthRequest().Update(video);
}
but i get this error:
Object reference not set to an instance of an object
on the last line.
what am i doing wrong?
thanks
May be is the same problem reported here, with a different error message..
YouTube API .NET C# editing video problem
Anyone have an example of creating a signed URL with an expiration using ASP .Net? I'm exploring using LitS3 or ThreeSharp in my project, and have not seen any specific methods to do this in either of those projects. Thanks.
Here's what worked for me with the AWS SDK and MVC 3 (based on the answers above and what I found on http://www.ec2studio.com/articles/s3.html):
public ActionResult GetS3Object(string bucket, string key)
{
string accessKeyID = ConfigurationManager.AppSettings["AWSAccessKey"];
string secretAccessKeyID = ConfigurationManager.AppSettings["AWSSecretKey"];
using (AmazonS3 client = Amazon.AWSClientFactory.CreateAmazonS3Client(accessKeyID, secretAccessKeyID))
{
GetPreSignedUrlRequest request = new GetPreSignedUrlRequest()
.WithBucketName(bucket)
.WithKey(key)
.WithExpires(DateTime.Now.Add(new TimeSpan(7, 0, 0, 0)));
return Redirect(client.GetPreSignedURL(request));
}
}
using the amazon .net SDK
you can get preSignedUrl
using (AmazonS3 client = Amazon.AWSClientFactory.CreateAmazonS3Client("your access key ID", "you secret key"))
{
GetPreSignedUrlRequest getPreSignedUrl = new GetPreSignedUrlRequest().WithBucketName(bucketName);
getPreSignedUrl.Key = key;
getPreSignedUrl.Expires = DateTime.Now.AddSeconds(60);
}
Found this (mentioned in this thread in the AWS discussion forums) class library for generating signed URLs in Amazon S3. If anyone has any additional suggestions/methods to try, let me know.
Edit: ThreeSharp has the functionality I was looking for. From the ThreeSharpConsoleSample app:
using (UrlGetRequest request = new UrlGetRequest("mytestbucket", "mytestfile.txt"))
{
request.ExpiresIn = 60 * 10000;
using (UrlGetResponse response = service.UrlGet(request))
{
Console.WriteLine("Try this url in your web browser (it will only work for 60 seconds)\n");
string url = response.StreamResponseToString();
Console.WriteLine(url);
}
}
Console.WriteLine("\npress enter >");
Console.ReadLine();