MVC And Web Application Administrative Tasks - How It Will Be Treated
Jan 12, 2010
I am little bit confuse with Asp.net MVC Area.
When we talk about WebForms we say, for Administrative tasks, you must have an Admin folder to separate the admin task.
In MVC how i will treat my Admin tasks?
I will go for Admin Area or Admin Controllers,
Because if i will write controller for Admin tasks, each and every task will be written in one controller (AdminController) or if i will write Area -> Controller, means i will need to write at-least two controllers for each feature.
Second if we breaks the application in Areas (as modules) how i will manage Admin task for each Area.
I am logged in as the administrator when I installed an application named pdflatex.exe on my server. This application works as a converter from LaTeX input file to Pdf file. I host an Asp.net MVC 3 application running under an Application Pool Identity with Load User Profile = True. The Asp.net MVC 3 code contains a code that executes pdflatex.exe using System.Diagnostic.Process instance as follows:
Process p = new Process(); p.EnableRaisingEvents = true; p.Exited += new EventHandler(p_Exited); p.StartInfo.Arguments = "-interaction=nonstopmode " + inputpath; p.StartInfo.WorkingDirectory = @"c:mydomain.comworking"; p.StartInfo.UseShellExecute = false; p.StartInfo.FileName = "pdflatex.exe"; p.Start(); p.WaitForExit();
From the scenario above, the web application runs under a restricted acount but it executes an external application under a default account that I don't know. Can an application running under a less privileged account start a process executing another application under an administrative account?
I have just started to look at the new "System.Threading.Tasks" goodness in .Net 4.0, and would like to know if there is any build in support for limiting the number of concurrent tasks that run at once, or if this should be manually handled.
E.G: If I need to call a calculation method 100 times, is there a way to set up 100 Tasks, but have only 5 execute simultaneously? The answer may just be to create 5 tasks, call Task.WaitAny, and create a new Task as each previous one finishes. I just want to make sure I am not missing a trick if there is a better way to do this.
As part of the web application I am working on there will be functionality to export data from the web application into a windows application copying the data between the database for the web application and the windows application. The databases for these two programs could have been combined but are being kept apart for simplicity.The utility to export the data can be triggered manually from the web application but it is also required that this task can be scheduled to run by the user (once a day, on web app shutdown etc)
I envisage this to be run as a service - I have created services for windows applications before but this is the first time I have needed to create this for a web application. Searching on goggle, I have found an msdn magazine article that suggests creating a web service and then creating a windows service which would call into this web service. So in my situation, I am thinking that I would create a web service which would contain the data transfer functionality between the web application and the windows application. Then I would create a windows service which would be installed as part of installing the web application, which would then call into the web service (at pre-defined intervals) using settings configured by the user within the web application (so that the data transfer functionality can be scheduled).Does this seem the correct solution? I would appreciate any advice on how I might achieve the above.
I'm writing an ASP.NET MVC site where I need to have a "Tasks" application that runs alongside the website. Such a "Tasks" application would collect data at set intervals and insert it into the database.
Of course, I could write a simple Console Application and use the Windows Task Scheduler to run it, but my site is being hosted by GoDaddy and I only have medium trust permissions.
Are there any methods for implementing such functionality while not violating medium trust permissions?
One method that I'm considering is a method in the site itself that gathers data, waits for a long time, and then gathers data again. Would that interupt users' connection to the site?
I'm attempting to configure a webdav server example application [URL] to run on IIS6 (Win2003 Server). The application runs correctly on my dev machine (Win7, IIS7.5). When I attempt to map a drive to the DAV share, several requests are issued, including one OPTIONS request and two PROPFIND requests. In Fiddler, I see that these are transmitted correctly. However, the response is always the content of the default page on the site. If I look at the IIS logs, the requests are logged as GETs instead of OPTIONS or PROPFIND. UrlScan is disabled, but I went ahead and added OPTIONS and PROPFIND to the list of allowed verbs (since I'm running out of ideas).
I have an MHTML file which has embedded images. The MHTML is generated on the server and then I will typically deliver the file using a BinaryWrite. I've also tried Server.Transfer, Response.Write after converting to ASCII and writing the file to disk and using a Response.WriteFile. In any of these cases the resulting file is not (it appears) treated as an mht file. For setting the image, I've tried Content-ID and Content-Location. The image URL shows up as cid:example1 when viewed in IE8. When opening up the file after saving to disk it shows up as mhtml:file://C:Documents and Settings enjynitoDesktopoutput634172401776447258.mht!cid:example1. Or while browsing with one of the methods that work you get [URL]
The Output.MimeType is message/rfc822. I've also tried application/octet-stream and multipart/related. Writing the file to disk and using a Response.Redirect works. Accessing the file with a direct URL works. Saving the file to disk and then opening the file works. It seems IE is assuming an HTML result to the request and not deciphering the new content type. But you can do things like this for dynamic style sheets, scripts, etc... so I don't really believe that. I couldn't see any glaring differences. I just tried and the BinaryWrite works fine in Opera. If I absolutely have to worry about writing to a temporary directory and then redirecting to the file I will. I was just hoping to avoid having to clean up the temporary files. Is what I want to do not possible? An example of writing the file is below.
I was following a MSDN walkthrough [URL] which is a very simple ASP.NET example with Visual Studio 2010:
· I have a simple database table with a timestamp column;
· I created a "Linq to SQL Class", and drag the table from Server Explorer onto it;
· I dragged a LinqDataSource onto the web page and pointed it to the dbml;
· I dragged a DetailsView onto the web page using the LinqDataSource.
· I enabled editing on the data source.
When I run, the time stamp column is also displayed on the DetailsView as something like "AAAAAAAAB9Y=". Then, when I change the "EmployeeName" and update, I got following exception: Failed to set one or more properties on type person. Cannot convert value of parameter 'tstamp' from 'System.String' to 'System.Data.Linq.Binary'. I was strictly following the MSDN walkthrough. I tried multiple times, I even installed Visual Studio 2010 SP1 Beta. But it consistently through this exception. Can someone shed some light on this? Not a encouraging start form someone thinking to learn the lastest Microsoft stuff!
I was following a MSDN walkthrough, which is a very simple ASP.NET website with Visual Studio 2010: I have a simple database table with a timestamp column;I created a "Linq to SQL Class", and drag the table from Server Explorer onto it;I dragged a LinqDataSource onto the web page and pointed it to the dbml;I dragged a DetailsView onto the web page using the LinqDataSource.I enabled editing on the data source.When I run, the time stamp column is also displayed on the DetailsView as something like "AAAAAAAAB9Y=".Then, when I change the "EmployeeName" and update, I got following exception: Failed to set one or more properties on type person. Cannot convert value of parameter 'tstamp' from 'System.String' to 'System.Data.Linq.Binary'. I was strictly following the MSDN walkthrough. Can someone shed some light on this? Not a encouraging start form someone thinking to learn the lastest Microsoft stuff!dfsaf
I've got a details view control, default set to Insert which I've added file upload controls. I've used a button to begin the upload process and add the other data to the database. The weird thing is that if I use FireFox to enter the data and upload the files, everything works fine but it works slightly differently in IE8. The difference is that when I browse for a file in FireFox, upload it and store the file name, it returns just the file name e.g. myPic.jpg. However, when I upload with IE8 it stores the entire route to the file e.g. C:/Users/Users/Site/myPic.jpg Why would a browser treat these things differently? And, is there a way to fix it to work on both browsers?
I am a beginner of C# programming. I have read a few books about C#.net. But I cannot find some exercises in the books. Someone told me to build up a blog to practice my coding.
But it is a huge task for a beginner. I just want some tasks to have a step by step learning process.
I used Castle Windsor before and had this routine that fired the certain method of all classes that implement a certain interface.If I recall correctly, the interface was IBootStrapTask and only had an excecute method. Then, for instance, I'd place all my route registrations in one of these, and know it get fired on application startup.Have to admit I did not understand the code to well, so I'm even more unsure how can I do this. I'm using structure map now. (still knowing very little about it)
In my ASP.NET website, I am having a function which has to be automatically performed once every 2-3 mins on its own, i.e. without user intervention. This function contains database access.
Can I use threading to perform this process in background?
If Yes, How can I use that?
Edit
Also I am not looking for a solution which includes windows service because I am using shared hosting. So I dont have all the rights to access the host computer.
We have a timer process (a JQuery plugin) that redirects after X number of minutes to the login page, all via JavaScript. When the timer hits zero, I want to run a task (could be anything; however, in this specific scenario, it's a web service call).
The issue I'm having is the web service that runs with the finish-up processes is not being called. The web service call happens, the redirect happens, I don't see any errors (I have try/catch statements around the setTimeout call), but no WS call.
I need reliable way to run 10 different tasks simultaneously. For instance the first one would be sending emails, while the next one is cleaning rows from a specific table... so on an so forth.
I've used the Thread class and while it works well on my development machine (VS2010 internal web server) non of these threads seems to be working at all on my production server. And I don't know of an effective way to debug the problem on the production server.
I saw this technique which encourage you to register cache objects. Since the application fires a callback when a cached item expires, then it's possible to run any code to mimic threading behavior. It seems a little Micky Mouse like.
This is my first forray into ASP.NET MVC, having been doing WebForms for nearly 6 years now. I've read through various tutorials and guides on getting started with MVC, but I've a few questions about how you're meant to do things:
UserControls for entities
In an application I wrote a few years ago (using WebForms) there were many entities that had an associated postal address (which existed as an instance of an Address class), so I created a UserControl that contained fields for working with addresses. During the page lifecycle I would pass the business object's .Address property to the UserControl for display and for population upon a successful and valid postback. How would I do something like this in MVC? My current project has a similar situation where common sets of fields are repeated throughout the application and all 'map' to the same class.
Modifying the page/view on 'postback'
Say I'm working on a data-entry form for an online B2B ordering system, where the user manually enters order items into a series of textboxes arranged in a table. The system can only provide so-many textboxes at a time (usually 5 or 10). If the user ran out of textboxes they would click an "Add more rows" button that performed a postback that was caught by that button's server-side .Click event handler. The page's class would then add more rows to the page; ASP.NET's stateful nature made this easy to implement. But in MVC there is no ViewState and I haven't found much information about how you'd do this, or anything like this. All of the tutorials and guides assume a form posting is only for data submission.
Multiple tasks per page/form
In a similar vein to the above, how do you create views that perform multiple tasks? In my above example I cited a webform that had two buttons: one to submit the form for actual processing, and another button that just modified the page (by adding more data-entry rows).Given that Controllers' actions are bound to URIs rather than what combination of fields were submitted, does this mean that I would have to interpret the posted data myself and branch based on that?
Finally, in many web applications you have the main form in the middle, but also things on the periphary of the page (e.g. a sidebar) that might have their own logic. For example, in one WebForms application I wrote last year there was a 'Quick contact' form in a UserControl located elsewhere on the page. When the user clicked the form's button the UserControl's logic handled the postback details independently of the page containing the UserControl (but there was only one <form> element in the whole rendered page). The user was returned to the page they clicked the button on, with everything in identical state as to how it was before, exccept for the UserControl which reported that the email was sent. Again, MVC's stateless nature would make something like this hard to implement, unless there are some techniques not covered in the tutorials?
I am experimenting AsyncController feature. What I did is set up two tasks to run in parallel. As in the code below, the problem is that sometime all tasks finished and return successfully, sometime only one task finish and sometime each task finish half of it's work and return. It is weird, what did I do wrong?
I have realized that Trace.Write is not a good way of tracing as it is gives you the time since last entry which makes no sense if more threads are writing.
I am writing a quick-and-dirty in-house ASP.NET application that needs to be able to run a task after a specific period of time. If it was a proper application, I'd probably use a windows service but I don't really want to bother with the extra complexity of that.I could put code in the BeginRequest handler to check whether any such tasks are due, but of course nothing would happen if nobody is using the application.at the moment the best option I can think of is something like ShellExecute("nohup sleep 1000; wget http://server/dummypage.aspx") (if you'll excuse the mixed windows/unix nomenclature).
I would like to makea windows service. whenever the user of my ASP.NET application has to do a time-consuming task, the IIS would give the task to the service which will return a token(a temporary name for the task) and in the background the service would do the task. At anytime, the user would see the status of his/her task which would be either pending in queue, processing, or completed. The service would do a fixed number of jobs in parallel, and would keep a queue for the next-incoming tasks. In addition there would be a WinForms application for system administrator that would allow adding special ADMIn tasks such as "Clean orphaned files" or "archive data of inactive users".
Can you point me to something that can jump start me on this as a whole concept - I know I can google for windows services and I am able to do it myself from scratch but time is of the Essence so maybe you know of something that is already there and i can use block to build out of.
I'm looking for ways to improve a web page that initiates a long-running (>2 minutes) server-side task. The current version of the page just clocks for the full duration of the task, which can be very frustrating to the user.
I already have a few ideas about how I could improve the user's experience, but they all would involve the use of AJAX to some extent. Because of previous experiences that I've had on this project, I know that not all users have JavaScript enabled or available.
Assuming that the server-side process has already been optimized as much as possible, what else could I do to improve the experience of all users as much as possible?
and so on (many more records). Now, whenever a record reaches its' end time, how can I execute SQL commands to delete that data (or mark as finished) and UPDATE another table?
This needs to be running constantly so I was thinking of building it into a Windows Service but can you suggest a better way of doing it?